Document not updated in time between threads

The document I’m saving here is not updated when observer calls my completion handler is called on MainThread.

Can anyone help?

Database.sharedIntance.getManager().backgroundTellDatabaseNamed(database, to: { (db: CBLDatabase!) -> Void in
        let document = db.documentWithID(key)

        // Add Observer to document
        if document != nil && completionClosure != nil {
            let mainQueue = NSOperationQueue.mainQueue()
            NSNotificationCenter.defaultCenter().addObserverForName(kCBLDocumentChangeNotification, object: document, queue: mainQueue) {
                (notification) -> Void in
                debugPrint(notification.userInfo!)
                if let change = notification.userInfo!["change"] as? CBLDatabaseChange {
                    debugPrint("This is a new revision, %@", change.revisionID);
                    completionClosure?()
                }
            }
        }

        do {
            var properties = document?.properties
            if properties == nil {
                properties = serializedObject
            } else {
                properties?.merge(withDictionary: serializedObject)
            }
            try document?.putProperties(properties!)
        } catch {
            let nsError = error as NSError
            debugPrint("Failed to write object with key: \(key) to cache with error: \(nsError.localizedDescription)")
            ThreadController.performBlockOnMainQueue{
                completionClosure?()
            }
        }
    })