 (defn clear-rows! [game]
   (let [completed-rows (completed-rows (:pieces @game))]
     (when (not (empty? completed-rows))
-      (swap! game #(update-in % [:pieces] clear-rows-from-pieces)))
+      (swap! game update-in [:pieces] clear-rows-from-pieces))
     (count completed-rows)))
 
 ; ---------- Rendering ----------


(defn start-new-game! [game]
  (reset! game starting-state)
  (swap! game (fn [g] (-> g (assoc :level 1) (assoc :score 0))))
  (add-next-falling-piece! game))

(defonce game (atom starting-state))


(defn move-falling-piece! [game dir]
  (try
    (swap! game update-in [:falling-piece] #(move-piece % dir))
  (catch js/Error e)))

(defn make-falling-piece-fall! [game] (move-falling-piece! game :down))

(defn rotate-falling-piece! [game]
  (try
    (swap! game update-in [:falling-piece] rotate-piece)
  (catch js/Error e)))

(defn entered-board? [piece]
