                     println("Set unknown user state to 1")
                     data.setUserStatus("1")
                 }else{
-                    /*
+                    
                     self.inBounds++
-                    if self.inBounds > 20 {
+                    if self.inBounds > 39 {
                         if !isIn {
                             isIn=true
                             let state: String = CoreDataHelper().getUserStatus()
-                            if state == "0" || state == "-2" || state == "1" {
+                            if state == "0" || state == "-2" || state == "-1" {
                                 message = "Setting new state"
-                                //self.setUserState("1")
+                                self.setUserState("1")
                             }
                         }
                         self.inBounds = 0
                     }
-                    */
+                    
                 }
             
                 if(nearestBeacon.proximity == lastProximity ||

                    data.setUserStatus("0")
                }
                else{
                    /*
                    self.outOfBoundsCount++
                    if outOfBoundsCount > 20 {
                        if isIn {
                            isIn = false
                            let data: CoreDataHelper = CoreDataHelper()
                            let state: String = data.getUserStatus()
                            if state == "1" {
                                message = "sending new state"
                                
                                //self.setUserState("0")
                            }
                        }
                        self.outOfBoundsCount = 0
                    }
                    */
                }
            }
            NSLog("%@", message)

    func applicationWillTerminate(application: UIApplication!) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
        // Saves changes in the application's managed object context before the application terminates.
        
        var data:CoreDataHelper = CoreDataHelper()
        var backgrounder:HTTPBackground = HTTPBackground()
        self.completionHandler = {}
