       (`1 nil)
       ((guard (eq 0 current-session-pos))
        (car (last sessions)))
-      (_ (seq-elt sessions (- current-session-pos 1))))))
+      (_ (seq-elt sessions (cl-decf current-session-pos))))))
 
 (cl-defun mesh:find-missing-index (fn lst)
   (cl-letf ((indices (seq-sort #'< (seq-map fn lst))))

      ((guard (eq 0 current-tab-pos))
       (car (last tabs)))
      (_
       (seq-elt tabs (- current-tab-pos 1))))))


(cl-defmethod mesh:find-next ((current-session mesh:session) sessions)
  (cl-letf* ((current-session-pos (cl-position
                                   current-session
                                   sessions)))
    (pcase (- (length sessions) 1)
      (`0 nil)
      ((pred (eq current-session-pos))
       (car sessions))

              (cl-position pane panes)))
    (cond ((eq (length panes) 1)
           nil)
          ((eq (cl-decf (length panes)) current-position)
           (car panes))
          ((< current-position (cl-decf (length panes)))
           (cl-nth-value (cl-incf current-position) panes))
          (t nil))))

