                     break
                 }
             }
-            self.sortedschedules = self.expandedData!.sorted { (di1, di2) -> Bool in
+            self.sortedschedules = self.expandedData?.sorted { (di1, di2) -> Bool in
                 if (di1.value(forKey: "start") as? Date)!.timeIntervalSince((di2.value(forKey: "start") as? Date)!) > 0 {
                     return false
                 } else {


    // Expanding and sorting Scheduledata
    private func sortAndExpandScheduleTasks() {
        for i in 0 ..< self.schedulesNSDictionary!.count {
            let dict = self.schedulesNSDictionary![i]
            let dateStop: Date = (dict.value(forKey: "dateStop") as? String)!.en_us_date_from_string()
            let dateStart: Date = (dict.value(forKey: "dateStart") as? String)!.en_us_date_from_string()

    init(allschedules: Allschedules?) {
        guard allschedules != nil else { return }
        self.expandedData = [NSDictionary]()
        self.scheduleConfiguration = allschedules?.getallschedules()
        self.setallscheduledtasksNSDictionary()
        self.sortAndExpandScheduleTasks()
    }
