         
         let startDate = formatter.date(from: "2017-01-01")!
         let endDate = formatter.date(from: "2017-12-31")!
+        
         return ConfigurationParameters(startDate: startDate,endDate: endDate)
     }
 }
 
 extension CalendarViewController: JTAppleCalendarViewDelegate {
+
     func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
         guard let validCell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "customCell", for: indexPath) as? CustomCalendarCell else {
             return JTAppleCell(x: 0, y: 0, w: 75, h: 75)
         }
-        validCell.dateLabel.text = cellState.text
-        if cellState.dateBelongsTo == .thisMonth {
-            validCell.dateLabel.textColor = UIColor.black
-        }else{
-            validCell.dateLabel.textColor = UIColor.lightGray
-        }
-        self.handleSelectedCell(view: validCell, date: date, cellState: cellState)
-        self.handleScheduleMark(view: validCell, date: date, cellState: cellState)
+        self.handleDefaultCell(view: validCell, date: date, cellState: cellState, selectedDates: calendar.selectedDates)
         return validCell
     }
     
     func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
-        guard let validCell = cell else{return}
-        if let validData = self.dummySchedule[date.toString(format: self.formatter.dateFormat)] {
-            self.detailData = validData
-        }else{
-            self.detailData = [String]()
-        }
-        detailView.reloadData()
-        self.handleSelectedCell(view: validCell, date: date, cellState: cellState)
-        self.handleScheduleMark(view: validCell, date: date, cellState: cellState)
+        guard let validCell = cell as? CustomCalendarCell else {return}
+        self.handleDefaultCell(view: validCell, date: date, cellState: cellState, selectedDates: calendar.selectedDates)
     }
     
     func calendar(_ calendar: JTAppleCalendarView, didDeselectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
-        guard let validCell = cell else{return}
-        self.handleSelectedCell(view: validCell, date: date, cellState: cellState)
-        self.handleScheduleMark(view: validCell, date: date, cellState: cellState)
+        guard let validCell = cell as? CustomCalendarCell else {return}
+        self.handleDefaultCell(view: validCell, date: date, cellState: cellState, selectedDates: calendar.selectedDates)
     }
     
     func calendar(_ calendar: JTAppleCalendarView, headerViewForDateRange range: (start: Date, end: Date), at indexPath: IndexPath) -> JTAppleCollectionReusableView {

    @IBOutlet weak var shiftSession16: UIView!
    @IBOutlet weak var shiftSession20: UIView!
}

    @IBOutlet weak var detailView: UITableView!
    @IBOutlet weak var calendarView: JTAppleCalendarView!
    
    var counter = 0
    let formatter = DateFormatter()
    let dummySchedule = [
        "2017-06-02":["siang","malam"],
