             print("Error While Deleting Note: \(error.userInfo)")
         }
         // Save updated notes to CoreData
-        addNotesToCoreData(notesArray: newNotes)
+        addNotesToCoreData(notesArray: updatedNotes)
     }
     
     

        }
    }
    
    func updateCoreDataNotes(newNotes: [AnyObject]) {
        print("Update notes")
        var localNotes = [NSManagedObject]()
        // Get access to CoreData managedContext

        }
        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 {
