               executor (:executor st)
               clock (:clock st)]
           ;; TODO: Use (compare-and-set!) instead to avoid a race-condition
-          (swap! state (fn [s] (-> s (assoc :status :running
-                                            :scheduled-future (schedule-next
-                                                               clock
-                                                               (first timeline)
-                                                               executor
-                                                               #(callback state timeline clock trigger executor)))))))
+          (swap! state (fn [st] (-> st (assoc :status :running
+                                              :scheduled-future (schedule-next
+                                                                 clock
+                                                                 (first timeline)
+                                                                 executor
+                                                                 #(callback state timeline clock trigger executor)))))))
         :ok)))
+
   (stop [_]
     (when-let [fut (:scheduled-future @state)]
       (.cancel fut false))

  (Clock/tickSeconds (ZoneId/systemDefault)))

(defn now
  ([]
   (ZonedDateTime/now))
  ([clock]
   (ZonedDateTime/now clock)))

(defn just-now "Now, but truncated to the nearest second"
  ([] (.truncatedTo (now) (ChronoUnit/SECONDS)))

    :ok)

  (pause [_]
    (let [st @state]
      (when-let [fut (:scheduled-future st)]
        (.cancel fut false))
      (swap! state (fn [st] (-> st (assoc :status :paused) (dissoc :scheduled-future))))
      :ok))

  (resume [_]
    (let [st @state]
      (when (= :paused (:status st))
