                 }
 
                 var dif = s - t
-                if dif < 0 {
+                if dif <= 0 {
                     dif += session.cycle!.int64Value
                 }
                 if !session.isInPeriod(time: time + dif) {

                    if exceptions != nil && !exceptions!.isEmpty {
                        let future = time + dif
                        var exDif = Int64.max

                        for i in 0 ..< exceptions!.count {
                            recursiveCount += 1
                            let ex: Session = exceptions![i]
                            if isInSession(ex, future) {
                                exDif = min(nextChange(time: time + ex.remaining(time: future)) + dif, exDif)
                            }
                        }
                        dif = min(exDif, dif)
                    }
                } else {
                    debugPrint("TimeTable", "Negative time difference: ", dif)

    }

    func nextChange(time: Int64) -> Int64 {
        let currentSession = findCurrentSession(time: time)
        if currentSession != nil {
            let nearestException = findNearest(exceptions, nil, time)
