     {
         if error != nil { self.publish(notification: .error(.unknownError)) }
         
-        if let i = self.connectedPeers.index(where: { $0.id == peripheral.identifier }) {
-            let peer = self.connectedPeers[i]
-            
-            self.connectedPeers.remove(at: i)
-            
+        if let peer = (Clink.Configuration.peerManager ?? self).getSavedPeer(withId: peripheral.identifier) {
             self.publish(notification: .disconnected(peer))
         }
         

        }
    }
    
    public func getSavedPeer(withId peerId: UUID) -> Clink.Peer? {
        guard let peerDict = UserDefaults.standard.dictionary(forKey: peerId.uuidString) else { return nil }
        
        return Clink.Peer(dict: peerDict)
    }
    
    public func getSavedPeers() -> [Clink.Peer] {
        return (UserDefaults.standard.stringArray(forKey: savedPeerIdsDefaultsKey) ?? []).flatMap { uuidString in
            guard let uuid = UUID(uuidString: uuidString) else { return nil }
            

public class Clink: NSObject, BluetoothStateManager {
    static public let shared = Clink()
    
    //    fileprivate var connectedPeers: [ClinkPeer] = []
    fileprivate var activePeripherals: [CBPeripheral] = []
    fileprivate var localPeerData = Data()
    fileprivate var activePairingTasks = [PairingTask]()
    fileprivate var notificationHandlers = [UUID: NotificationHandler]()
