     (if (< i (dec (count data))) 
       (let [e (nth data i)] 
         (if (e :cont)
-          (first @(e :cont))
+          (first @(get-in e [:cont :data]))
           e))
-      (if-let [cont ((last data) :cont)]
+      (if-let [cont (get-in (last data) [:cont :data])]
         (nth-history (- i (dec (count data))) @cont)
         nil))))
 
 (defn len [unrolled-list]
   (+ -1 (count unrolled-list) 
     (when-let [end (last unrolled-list)]
-      (when-let [n (end :cont)] (len @n)))))
+      (when-let [n (get-in end [:cont :data])] (len @n)))))
 
 (def history-indicator
   {:id "indexMorph"

          pre-branch (vec (take rel-index @branch-part)) 
          post-branch (vec (drop rel-index @branch-part))
          ; insert the branching point into the old branch
          branched-branch (conj pre-branch {:cont (atom post-branch) :fork new-branch})]
        ; update the old branch with the inserted version
        (reset! branch-part branched-branch)
        ; let current branch pointer point to new branch

(def current-branch (atom {:id (generate-uuid) :data (atom [])}))

;; global atom referencing the total history graph
(def app-history (atom {:root @current-branch :data (@current-branch :data)}))

;; ffd
(def history-view)

(defn most-recent-state []
  (let [l (len @(@current-branch :data))]
        (when (> l 0) (nth-history (- l 2)))))

(defn switch-to-branch [branch]
  (prn "old branch id: " (@current-branch :id))
