                     delegate?.connectedToPeer(peerID)
                 } else {
                     DLog("%@", "not connected to \(session.hashValue)")
-                    DLog("%@", "peersInSession \(self.session.peersInSession)")
+//                    DLog("%@", "peersInSession \(self.session.peersInSession)")
                     
                     // If session.connectedPeers is empty, it implies that either:
                     // - Self is disconnected from the session
                     // - The session has no other connected peer
                     // Combine with peersInSession count > 1, we can be certain that
                     // self is disconnected.
-                    if self.session.connectedPeers.isEmpty && self.session.peersInSession.count > 1 {
+                    
+                    if self.session.connectedPeers.isEmpty && self.host == peerID {
                         DLog("%@", "Self was removed")
-                        self.session.peersInSession.remove(myPeerId)
+                        
                         delegate?.disconnectedFromSession()
-                    } else {
-                        DLog("%@", "Self was not removed")
-                        DLog("%@", "Current host: \(self.session.host)")
-                        
-                        // If the removed item is the current host
-                        if self.session.host == peerID {
-                            var nextHost = peerID
-                            
-                            // Assign a new host as the first item in peersInSession set that is not the old host
-                            for peer in self.session.peersInSession {
-                                if peer != peerID {
-                                    nextHost = peer
-                                    break
-                                }
-                            }
-                            DLog("%@", "Next potential host: \(nextHost)")
-                            
-                            // If the current item is the next in line, convert it to a host
-                            if myPeerId == nextHost {
-                                DLog("%@", "my peer is the next host")
-                                // Convert current item into a host
-                                self.session.host = myPeerId
-                                DLog("%@", "New host \(self.session.host?.displayName)")
-                                stopSearchingForHosts()
-                                startAdvertisingHost()
-                            }
-                        }
                     }
                 }
                 
-                delegate?.connectedPeersInSessionChanged(self.session.connectedPeers, host: self.session.host)
+                delegate?.connectedPeersInSessionChanged(self.session.connectedPeers)
             }
     }
     
     // Handles incomming NSData
     public func session(session: MCSession, didReceiveData data: NSData,
         fromPeer peerID: MCPeerID) {
-            DLog("%@", "Data received: \(data)")
+//            DLog("%@", "Data received: \(data)")
             delegate?.handleDataPacket(data, peerID: peerID)
     }
     

    // This method is async
    public func sendData(data: NSData, mode: MCSessionSendDataMode) -> Bool {
        do {
            DLog("%@", "send data to host: \(data)")
            try session.sendData(data, toPeers: session.connectedPeers, withMode: mode)
        } catch {
            DLog("%@", "send data failed: \(data)")
            return false
        }
        
        return true
    }
    
    // Debug mode
    private func DLog(message: String, _ function: String) {
        if debugMode {

        guard foundHosts.contains(peerID) else {
            return
        }
        DLog("%@", "lostPeer: \(peerID)")
        let index = foundHosts.indexOf(peerID)!
        foundHosts.removeAtIndex(index)
        delegate?.foundHostsChanged(foundHosts)
