         if manager.deviceMotionAvailable{
             manager.deviceMotionUpdateInterval = interval
             manager.startDeviceMotionUpdatesToQueue(NSOperationQueue()){
-                (data: CMDeviceMotion!, error: NSError!) in
-                
-                if let isError = error{
-                    NSLog("Error: %@", isError)
-                }
-                valX = data.gravity.x
-                valY = data.gravity.y
-                valZ = data.gravity.z
+                (data, error) in
+                
+                if let isError = error{
+                    NSLog("Error: %@", isError)
+                }
+                valX = data!.gravity.x
+                valY = data!.gravity.y
+                valZ = data!.gravity.z
                 
                 if values != nil{
                     values!(x: valX, y: valY, z: valZ)
                 }
                 
-                var absoluteVal = sqrt(valX * valX + valY * valY + valZ * valZ)
+                let absoluteVal = sqrt(valX * valX + valY * valY + valZ * valZ)
                 self.delegate?.getGravityAccelerationValFromDeviceMotion!(valX, y: valY, z: valZ)
             }
             

        if manager.deviceMotionAvailable{
            manager.deviceMotionUpdateInterval = interval
            manager.startDeviceMotionUpdatesToQueue(NSOperationQueue()){
                (data: CMDeviceMotion!, error: NSError!) in
                
                if let isError = error{
                    NSLog("Error: %@", isError)
                }
                valX = data.userAcceleration.x
                valY = data.userAcceleration.y
                valZ = data.userAcceleration.z
                
                if values != nil{
                    values!(x: valX, y: valY, z: valZ)

    *  Discussion:
    *   Stops magnetometer updates.
    */
    @available(iOS, introduced=5.0)
    public func stopmagnetometerUpdates() {
        self.manager.stopMagnetometerUpdates()
        NSLog("Magnetometer Updates Status - Stopped")
