             addNotesToCoreData(notesArray: newNotes)
         }
         if updatedNotes.count > 0 {
-            updateCoreDataNotes(newNotes: updatedNotes)
+            updateCoreDataNotes(updatedNotes: updatedNotes)
         }
         if notesToDelete.count > 0 {
-            deleteNotes(notes: notesToDelete)
-        }
-    }
-    
-    func deleteNotes(notes: [NSManagedObject]) {
+            deleteCoreDataNotes(notes: notesToDelete)
+        }
+    }
+    
+    func deleteCoreDataNotes(notes: [NSManagedObject]) {
         // Get access to CoreData managedContext
         guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
         let managedContext = appDelegate.persistentContainer.viewContext

        guard let httpRequest = prepareHttpRequest() else { completeHandler(nil); return }
        Alamofire.request(httpRequest).validate().responseJSON { response in
            if response.result.isSuccess {
                completeHandler(response.result.value as? [AnyObject])
            } else {
                completeHandler(nil)

        }
        let localNotesDictionary = convertLocalNotesToDictionaryByID(notes: localNotes)
        // Remove old notes from CoreData
        for case let updatedNote as [String:AnyObject] in updatedNotes {
            managedContext.delete(localNotesDictionary[(updatedNote["id"] as! Int)]!)
        }
        do {
