     func travelDistanceUpdated(withDistance distance: Double)
 }
 
+enum DelayState {
+    case late(date: Date)
+    case onTime(date: Date)
+    case noDelay(date: Date)
+}
+
 class RouteTableViewCell: UITableViewCell {
 
     // MARK: Data vars

            Network.getDelay(tripId: tripId, stopId: stopId).perform(withSuccess: { (json) in
                if json["success"].boolValue {
                    guard let delay = json["data"]["delay"].int else {
                        self.hideLiveElements()
                        self.setDepartureTimeAndLiveElements(withRoute: route)
                        return
                    }
                    
                    let oneMinute = 60
                    if delay >= oneMinute {
                        let lateTime = direction.startTime.addingTimeInterval(TimeInterval(delay))
                        self.setLiveElementsToLate(withDepartureTime: lateTime)
                        
                        self.setDepartureTime(withStartTime: Date(), withDepartureTime: lateTime, late: true)
                    } else {
                        self.setLiveElementsOnTime()
                        self.setDepartureTimeOnTime()
                    }
                    
                     route.getFirstDepartRawDirection()?.delay = delay
                }
                else {
                    self.hideLiveElements()
                    self.setDepartureTimeAndLiveElements(withRoute: route)                }
            }, failure: { (error) in
                print("RouteTableViewCell setLiveElements(withStartTime:, withDelay:) error: \(error.errorDescription ?? "") Request url: \(error.request?.url?.absoluteString ?? "")")
                self.hideLiveElements()
                self.setDepartureTimeAndLiveElements(withRoute: route)
            })
        }
        else {
            self.hideLiveElements()
            if let route = route {
                self.setDepartureTimeAndLiveElements(withRoute: route)
            }
        }
    }

    private func hideLiveElements() {
        liveIndicatorView.setColor(to: .clear)
        liveLabel.textColor = .clear
    }
    
    private func setLiveElementsOnTime() {
        liveLabel.textColor = .liveGreenColor
        liveLabel.text = "On Time"
        liveIndicatorView.setColor(to:.liveGreenColor)
        
        liveLabel.sizeToFit()
        positionLiveIndicatorView(usingLiveLabel: liveLabel)
    }
    
    private func setDepartureTimeOnTime() {
        departureTimeLabel.textColor = .liveGreenColor
        arrowImageView.tintColor = .primaryTextColor
    }
    
    private func setLiveElementsToLate(withDepartureTime departureTime: Date) {
        liveLabel.textColor = .liveRedColor
        liveLabel.text = "Late - \(Time.timeString(from: departureTime))"
        liveIndicatorView.setColor(to: .liveRedColor)
        
        liveLabel.sizeToFit()
        positionLiveIndicatorView(usingLiveLabel: liveLabel)
    }
    
    private func setDepartureTime(withStartTime startTime: Date, withDepartureTime departureTime: Date, late: Bool) {
        let boardTime = Time.timeString(from: startTime, to: departureTime)
        departureTimeLabel.text = boardTime == "0 min" ? "Board now" : "Board in \(boardTime)"
        departureTimeLabel.textColor = late ? .liveRedColor : .primaryTextColor
        arrowImageView.tintColor = .primaryTextColor
        
        departureTimeLabel.sizeToFit()

    private func setDepartureTimeAndLiveElements(withRoute route: Route) {
        let isWalkingRoute = route.isRawWalkingRoute()

        if isWalkingRoute {
            setDepartureTimeToWalking()
            return
        }
        
        let delayState = getDelayState(fromRoute: route)
        setDepartureTime(withStartTime: Date(), withDelayState: delayState)
        setLiveElements(withDelayState: delayState)
    }
    
    @objc func updateLiveElementsWithDelay() {
