 //
 
 import UIKit
+import CoreMotion
 
 class ViewController: UIViewController, UITextFieldDelegate {
 
     @IBOutlet weak var goalLabel: UILabel!
     @IBOutlet weak var newGoalField: UITextField!
     
+    //MARK: class variables
+    let activityManager = CMMotionActivityManager()
+    let pedometer = CMPedometer()
+    let motion = CMMotionManager()
+    var totalSteps: Float = 0.0
+    
     let numberToolbar: UIToolbar = UIToolbar()
     
     override func viewDidLoad() {
         super.viewDidLoad()
         // Do any additional setup after loading the view, typically from a nib.
+        self.totalSteps = 0.0
+        self.startActivityMonitoring()
+        self.startPedometerMonitoring()
+        self.startMotionUpdates()
         
         if UserDefaults.standard.object(forKey: "stepGoal") == nil {
             UserDefaults.standard.set(100, forKey: "stepGoal")

        goalLabel.text = "Step Goal: \(goalNumber!)"

    }

}


    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
    }

    @IBAction func setGoal(_ sender: AnyObject) {
