       presentViewController(popoverVC!, animated: true, completion: nil)
       
     }
-      
       //All good
     else
     {
-      checkOK = true
-    }
-    
-    
-    
-    //everything is good so let's register
-    if checkOK {
-      
-      
-      //get the appdelegate and store it in a variable
-      let appDelegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
-      let context = appDelegate.stack!.context
-      
-      
-      //Check for already logged in user
-      let ent = entity(name: "User", context: context)
-      
-      
-      //Create the request
-      let request = FetchRequest<User>(entity: ent)
-      //Users that we have password for only
-      request.predicate = NSPredicate(format: "password != nil")
-      
-      
-      //Array to keep the users
-      var users = [User]()
-      
-      //Fetch the users and store them in the array
-      do{
-        users = try fetch(request: request, inContext: context)
-      }catch{
-        print("Error fetching users \(error)")
-      }
-      
-      
-      //Check if the username exists
-      var exists = false
-      
-      for i in users {
-        
-        if i.username == nameTextField.text{
-          exists = true
-          print("Name Exists")
+      
+        
         }
-      }
-      
-      
-      
-      //If it doesn't exist
-      if !exists{
-        
-        //Create the user
-        let user = User(context: context, id: "NON-YET", username: nameTextField.text!.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet()), avatar: UIImage(named: "Default-Avatar")!, status: .ONLINE, timezone: NSTimeZone.systemTimeZone())
-        
-        //Set the password
-        user.password = passwordTextField.text!
+      
+        
+        
         
         //User is automatically is added to CoreData, but not saved, so we need to call
         //save context next.

    
    
    //Name check
    if (nameTextField.text!.isEmpty){
      
      nameTextField.layer.borderColor = UIColor.redColor().CGColor
      nameTextField.layer.borderWidth = 1

  }
  
  
  //Function to return popovers as modals to all devices (iPhones by default present popovers as fullscreen, not as modals.).
  func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
    
    return .None
