      */
     @discardableResult
     public func remove(key: String, accessibility: CFString = kSecAttrAccessibleWhenUnlocked) -> Bool {
+        
+         // The lock prevents the code to be run simultaneously
+         // from multiple threads which may result in crashing
+        lock.lock()
+        defer { lock.unlock() }
+        
         let query = self.query()
         query[kSecAttrService] = hierarchicalKey(key)
         lastStatus = SecItemDelete(query)

    // MARK: Private functions to do all the work
    
    private func set(_ data: NSData?, key: String, accessibility: CFString = kSecAttrAccessibleWhenUnlocked) -> Bool {
        let hierKey = hierarchicalKey(key)

        let dict = service()

    }
    
    private func data(forKey key:String) -> Data? {
        
        // The lock prevents the code to be run simultaneously
        // from multiple threads which may result in crashing
        lock.lock()
        defer { lock.unlock() }
        
        let hierKey = hierarchicalKey(key)
        let query = self.query()
        query.setObject(hierKey, forKey: kSecAttrService as! NSCopying)
