         
         struct Scan {
             
+            var semaphore: Semaphore?
+            
             var peripherals = [Peripheral: (peripheral: CBPeripheral, scanResult: ScanData<Peripheral, Advertisement>)]()
             
             var foundDevice: ((ScanData<Peripheral, Advertisement>) -> ())?

    
    enum Operation {
        
        case connect(Peripheral)
        case discoverServices(Peripheral)
        case discoverCharacteristics(Service<Peripheral>)

        ]
        
        accessQueue.sync { [unowned self] in
            self.internalState.scan.peripherals = [:]
            self.internalState.scan.foundDevice = foundDevice
        }
        
        // store semaphore
        let semaphore = Semaphore(timeout: 60 * 10, operation: .scan)
        accessQueue.sync { [unowned self] in self.internalState.scan.semaphore = semaphore }
        defer { accessQueue.sync { [unowned self] in self.internalState.scan.semaphore = nil } }
        
        self.log?("Scanning...")
        
        self.internalManager.scanForPeripherals(withServices: nil, options: options)
        
        // wait
        try semaphore.wait()
        
        accessQueue.sync { [unowned self] in
            self.internalState.scan.foundDevice = nil
        }
