         let operation = CKQueryOperation(query: query)
         
         operation.recordFetchedBlock = { (record: CKRecord?) in
-            
-            guard let rawData = record?.value(forKey: self.recordKey) as? Data,
-                let annoatations = rawData.toAnnoatations else { return }
-            completed(annoatations)
+//            NSKeyedUnarchiver.unarchiveObject(with: self) as? [CustomPointAnnotation]
+            let data = record?.value(forKey: self.recordKey) as? Data
+            if let annotations = data.map(NSKeyedUnarchiver.unarchiveObject) as? [CustomPointAnnotation] {
+                completed(annotations)
+            }
+//            guard let rawData = record?.value(forKey: self.recordKey) as? Data,
+//                let annoatations = rawData.toAnnoatations else { return }
+//            completed(annoatations)
         }
         
         operation.queryCompletionBlock = { (cursor, error) in
-            guard error == nil else {
-                print(error?.localizedDescription ?? "Error")
-                return
-            }
+            let _ = error.map { print($0.localizedDescription)  }
+            
             
             //TODO: - end todo
         }

    func updateUserStatus(completed: @escaping (CKAccountStatus)->()) {
        
        container.accountStatus { (status, error) in
            if let error = error { self.text = "\(error)" }
            var statusString = ""
            
            switch status {
            case .available:
                print("iCloud account is logged in")
                self.requestPermission()
                
            case .restricted:
                statusString = "iCloud settings are restricted by parental controls or a configuration profile"
                
                
            case .noAccount:
                statusString = "the user not logged in"
                
                
            case .couldNotDetermine:
                statusString = "please try again"
                
            }
            
            if case .available = status {
                DispatchQueue.main.async {
                    self.text = statusString
                }
            }
            
            completed(status)

    
    
    func query(completed: @escaping ([CKRecord]?, Error?) -> ()) {
        let date = NSDate(timeInterval: -60.0 * 120 * 60, since: Date())
        let predicate = NSPredicate(format: "creationDate > %@", date)
        let query = CKQuery(recordType: recordType, predicate: predicate)
//        let query = CKQuery(recordType: recordType, predicate: NSPredicate(value: true))
        database.perform(query, inZoneWith: nil, completionHandler: completed)
    }
    
