     /// array of NSDictionary.
     /// - returns : none
     private func setallscheduledtasksNSDictionary() {
-        guard self.scheduleConfiguration != nil else { return }
         var data = [NSDictionary]()
-        for i in 0 ..< self.scheduleConfiguration!.count where
+        for i in 0 ..< (self.scheduleConfiguration?.count ?? 0) where
             self.scheduleConfiguration![i].dateStop != nil && self.scheduleConfiguration![i].schedule != Scheduletype.stopped.rawValue {
             let dict: NSDictionary = [
-                "dateStart": self.scheduleConfiguration![i].dateStart,
-                "dateStop": self.scheduleConfiguration![i].dateStop!,
-                "hiddenID": self.scheduleConfiguration![i].hiddenID,
-                "schedule": self.scheduleConfiguration![i].schedule,
+                "dateStart": self.scheduleConfiguration?[i].dateStart ?? "",
+                "dateStop": self.scheduleConfiguration?[i].dateStop ?? "",
+                "hiddenID": self.scheduleConfiguration?[i].hiddenID ?? -1,
+                "schedule": self.scheduleConfiguration?[i].schedule ?? "",
                 "profilename": self.scheduleConfiguration![i].profilename ?? NSLocalizedString("Default profile", comment: "default profile"),
             ]
             data.append(dict as NSDictionary)

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


    // Expanding and sorting Scheduledata
    private func sortAndExpandScheduleTasks() {
        for i in 0 ..< (self.schedulesNSDictionary?.count ?? 0) {
            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()
