                          (- (get-in instrument [:cur-touches (t :touch-id) :position :y])
                             (-> t :position :y)))
                        (filter-type "touchmove" touches))]
-    (first (sort (fn [a b] (max (.abs js/Math a) (.abs js/Math b))) distances))))
+    (or (first (sort (fn [a b] (max (.abs js/Math a) (.abs js/Math b))) distances))
+        0)))
 
 (defn record-touches
   [touches instrument]

  [instrument freq]
  (if (get-in instrument [:piano-keys freq :on?])
    (do
      (println "stop" (get-in instrument [:piano-keys freq :synth]))
      (.release (get-in instrument [:piano-keys freq :synth]))
      (assoc-in instrument [:piano-keys freq :on?] false))
    instrument))


(defn scroll
  [touches {playhead :playhead :as instrument}]
  (let [delta-ms (/ (max-scroll-distance touches instrument)
                    (instrument :px-per-ms))]
    (if (> (.abs js/Math delta-ms) 20)
      (-> instrument
          (assoc :scrolling? true)
          (assoc :playhead (+ playhead delta-ms)))
      (assoc instrument :scrolling? false))))

(defn delete-scrolled-notes
  [touches {notes :notes :as instrument}]
  (let [scroll-touch-ids (set (map :touch-id (filter-type "touchmove" touches)))
        delete-notes (group-by (fn [t] (and (nil? (t :off))
                                            (contains? scroll-touch-ids (t :touch-id))))
                               notes)]
    (-> instrument
        (assoc :notes (get delete-notes false))
        (->> (reduce-val->> stop-piano-key (map :freq (get delete-notes true)))))))

(defn handle-scrolling
  [touches instrument]
