         ]
 
     }
+    
+    override func viewDidDisappear(animated: Bool) {
+        runkeeperSwitch.removeFromSuperview()
+    }
+    
+    
     
     func mainSegmentControl(segment: UISegmentedControl) {
         if segment.selectedSegmentIndex == 0 {

    // VIEW DID APPEAR
    override func viewDidAppear(animated: Bool) {
        
        self.navigationController!.navigationBar.tintColor = UIColor.whiteColor()
        UITextField.appearance().keyboardAppearance = .Light
        UIStatusBarStyle.LightContent

        let navItem = UINavigationItem(title: "")
        navBar.setItems([navItem], animated: true)
        
        runkeeperSwitch.backgroundColor = UIColor.clearColor()
        runkeeperSwitch.selectedBackgroundColor = UIColor.whiteColor()
        runkeeperSwitch.titleColor = UIColor.whiteColor()
        runkeeperSwitch.selectedTitleColor = UIColor.protonBlue()
        runkeeperSwitch.titleFont = UIFont(name: "Nunito-SemiBold", size: 13.0)
        runkeeperSwitch.frame = CGRect(x: view.bounds.width - 205.0, y: 15, width: 200, height: 30.0)
        //autoresizing so it stays at top right (flexible left and flexible bottom margin)
        runkeeperSwitch.autoresizingMask = [.FlexibleLeftMargin, .FlexibleRightMargin]
        runkeeperSwitch.bringSubviewToFront(runkeeperSwitch)
        runkeeperSwitch.addTarget(self, action: #selector(HomeViewController.indexChanged(_:)), forControlEvents: .ValueChanged)
        
        tableView.frame = CGRect(x: 0, y: 340, width: width, height: height-100)
        self.view.addSubview(tableView)
