         return events
     }
     
-    func setCalendar(calendar: EKCalendar) {
-
+    private func setInUserCalendarForUser(user: User, calendarId: String) {
+        user.inUseCalendarId = calendarId
+        user.saveInBackground()
+    }
+    
+    private func setInUserCalendarForCurrentUserAsync(calendar: EKCalendar) {
+        
         let user = PFUser.currentUser() as! User
         let query = PFQuery(className: Calendar.parseClassName())
         

            if let remoteCalendar = rcalendar {
                print("Calendar Found")
                
                user.inUseCalendarId = remoteCalendar.objectId
                user.saveInBackground()
            }
            else {
                let pfcalendar = Calendar()

                pfcalendar.localEntity = String( calendar.calendarIdentifier )
                
                pfcalendar.saveInBackgroundWithBlock({ (saved, savingError) -> Void in
                    self.setInUserCalendarForUser(user, calendarId: pfcalendar.objectId!)
                })
            }
        }

    }
    
    func setCalendar(calendar: EKCalendar) {
        setInUserCalendarForCurrentUserAsync(calendar)
        
        self.calendar = calendar
    }
