                     }
                 })
             }
-        } else {
-            
         }
     }
     
     @IBAction func addTimeZoneAction(sender: AnyObject) {
         zonesArray.append("10:00-10:00")
-        self.isFromButton = true
-        self.picker?.pickerTitleLabel("From")
-        self.picker?.okButtonTitle.title = "Next"
-        self.picker?.hideShowDatePickerView(isToShow: true)
-        self.picker?.datePicker.minuteInterval = timeInterval
+        isFromButton = true
+        picker?.pickerTitleLabel("From")
+        picker?.okButtonTitle.title = "Next"
+        picker?.hideShowDatePickerView(isToShow: true)
+        picker?.datePicker.minuteInterval = timeInterval
     }
     
     

                self.picker?.cancelButtonTitle.title = "Cancel"
                self.picker?.okButtonTitle.title = "Next"
            }
        }) { (doneValue) in
            
            let tempArr: String?
            if (self.activeIndexPath != nil) {
                if doneValue != "" {
                    tempArr = self.generateTimeZoneArray(isFrom: self.isFromButton, fromToValue: self.zonesArray[(self.activeIndexPath?.row)!], withDoneValue: doneValue)
                    self.zonesArray[(self.activeIndexPath?.row)!] = tempArr!
                }
            } else {
                if doneValue != "" {
                    tempArr = self.generateTimeZoneArray(isFrom: self.isFromButton, fromToValue: self.zonesArray[self.zonesArray.endIndex - 1], withDoneValue: doneValue)
                    
                    if !self.isFromButton {
                        let arr = tempArr!.dashRemoval()
                        let dateFormatter = NSDateFormatter()
                        dateFormatter.dateFormat = "HH:mm"
                        
                        let startTime = dateFormatter.dateFromString(arr[0])!
                        let endTime = dateFormatter.dateFromString(arr[1])!
                        
                        
                        let userCalendar = NSCalendar.currentCalendar()
                        let hourMinuteComponents: NSCalendarUnit = [.Hour, .Minute]
                        let timeDifference = userCalendar.components(
                            hourMinuteComponents,
                            fromDate: startTime,
                            toDate: endTime,
                            options: [])
                        
                        if timeDifference.hour <= 0 || timeDifference.minute <= 0 {
                            self.displayAlertMessage("To time must be greater than \(arr[0])", alertDescription: "")
                        } else {
                            self.zonesArray[self.zonesArray.endIndex - 1] = tempArr!
                        }
                        
                    } else {
                        self.zonesArray[self.zonesArray.endIndex - 1] = tempArr!
                    }
                }
            }
            
            self.picker?.hideShowDatePickerView(isToShow: false)
            
            if self.isFromButton {
                self.picker?.hideShowDatePickerView(isToShow: true)
                self.picker?.pickerTitleLabel("To")
                self.picker?.okButtonTitle.title = "Done"
                self.picker?.cancelButtonTitle.title = "Prev"
                self.isFromButton = false
            } else {
                self.activeIndexPath = nil
                dispatch_async(dispatch_get_main_queue(), {
                    self.setChallengeButton.enabled = true
                    self.setChallengeButton.alpha = 1.0
                    self.tableView.reloadData()
                })
            }
        }
    }
    

}

private extension Selector {
    static let back = #selector(TimeFrameTimeZoneChallengeViewController.back(_:))
}

