         for characteristic in charcteristics {
 //            print("characteristic = \(characteristic) value = \(characteristic.value) UUID = \(characteristic.UUID) isNotifying = \(characteristic.isNotifying) isBroadcasted = \(characteristic.isBroadcasted)")
             // set notification for heart rate measurement
-            if characteristic.uuid.isEqual(CBUUID(string: "2A37")) {
+            if characteristic.uuid.isEqual(heartRateMeasurementCharacteristic) {
                 print("\(#function): Found a heart rate measurement characteristic")
                 peripheral.setNotifyValue(true, for: characteristic)
             }
             // read the body sensor location
-            if (characteristic.uuid.isEqual(CBUUID(string: "2A38"))) {
+            if characteristic.uuid.isEqual(sensorLocationCharacteristic) {
                 print("\(#function): Found a body sensor location characterstic")
                 peripheral.readValue(for: characteristic)
             }
             // write heart rate control point
-            if (characteristic.uuid.isEqual(CBUUID(string: "2A39"))) {
+            if characteristic.uuid.isEqual(heartRateControlPointCharacteristic) {
                 let valArray :[UInt8] = [1]
                 let valData = NSData(bytes: valArray, length: valArray.count)
                 peripheral.writeValue(valData as Data, for: characteristic, type: CBCharacteristicWriteType.withResponse)

    
    // connect to the found periperal
    func connectToPeripheral(_ peripheral: CBPeripheral) {
        _heartRateMonitor = peripheral;
        centralManager.connect(peripheral, options: nil)
    }
    

    
    // start scanning for devices (peripherals)
    func startScan() {
        if centralManager.centralManagerState == CBCentralManagerState.poweredOn {
            print("Scanning")
            let serviceUUIDs = [heartRateServiceUUID];
            centralManager.scanForPeripherals(withServices: serviceUUIDs, options: nil)
        }
    }
    
    // start scanning for devices (peripherals)
    func findDevice() {
        if centralManager.centralManagerState == CBCentralManagerState.poweredOn {
            print("Finding")
            if let deviceUUIDString = UserDefaults.standard.string(forKey: deviceIdKey) {
                let deviceUUID = UUID(uuidString: deviceUUIDString)!
                let deviceUUIDs = [deviceUUID];
                let knownPeripherals = centralManager.retrievePeripherals(withIdentifiers: deviceUUIDs)
                if knownPeripherals.count > 0 {
                    let peripheral = knownPeripherals[0] as CBPeripheral
                    connectToPeripheral(peripheral)
                }
