                 // If it's possible use existing scan - take if from the queue
                 self.lock.lock(); defer { self.lock.unlock() }
                 if let elem = self.scanQueue.findElement({ $0.acceptUUIDs(serviceUUIDs) }) {
-                    guard elem.UUIDs != nil else {
-                        return elem.observable
-                    }
-                    guard let serviceUUIDs = serviceUUIDs else {
+                    guard serviceUUIDs != nil else {
                         return elem.observable
                     }
 

                        self.centralManager.stopScan()
                        disposable.dispose()
                        do { self.lock.lock(); defer { self.lock.unlock() }
                            if let index = self.scanQueue.indexOf({ $0 == operation }) {
                                self.scanQueue.removeAtIndex(index)
                            }
                        }
                    }

                }
                .queueSubscribeOn(self.subscriptionQueue)
                .publish()
                .refCount()

                operationBox.value = operation
                return operation
            }()
            // Allow scanning as long as bluetooth is powered on
            return self.ensureState(.PoweredOn, observable: observable)
        }
    }

    // MARK: State


                    // filtered properly
                    return elem.observable.filter { scannedPeripheral in
                        if let services = scannedPeripheral.advertisementData.serviceUUIDs {
                            return Set(services).isSupersetOf(serviceUUIDs!)
                        }
                        return false
                    }
                }

                let scanOperationBox = MutableBox<ScanOperation>()

                // Create new scan which will be processed in a queue
                let operation = Observable.create { (element: AnyObserver<ScannedPeripheral>) -> Disposable in

                    // Observable which will emit next element, when peripheral is discovered.
                    let disposable = self.centralManager.rx_didDiscoverPeripheral
                        .map { (peripheral, advertisment, rssi) -> ScannedPeripheral in
                            let peripheral = Peripheral(manager: self, peripheral: peripheral)
                            let advertismentData = AdvertisementData(advertisementData: advertisment)
                            return ScannedPeripheral(peripheral: peripheral,
                                advertisementData: advertismentData, RSSI: rssi)
                        }
                        .subscribe(element)

                    // Start scanning for devices
                    self.centralManager.scanForPeripheralsWithServices(serviceUUIDs, options: options)
