             ny (inc y)]
         (if (piece-fits? piece x ny board)
           (swap! state assoc-in [:position 1] ny)
-          (do
-            (swap! state assoc :board (write-piece-to-board piece x y board))
-            (try-collapse!)
-            (spawn-piece!))))
+          (lock-piece!)))
       (recur))))
 
 ;;------------------------------------------------------------

    (if (piece-fits? new-piece x y board)
      (swap! state assoc :piece new-piece))))

(defn add-key-events
  "Add all the key inputs."
  []

        n (- (count board) (count cleared-board))
        new-board (into (vec (repeat n empty-row)) cleared-board)]
    (swap! state assoc :board new-board)))

(defn lock-piece!
  "Lock the current piece into the board."
  []
  (let [[x y] (:position @state)
        piece (:piece @state)
        board (:board @state)]
    (swap! state assoc :board (write-piece-to-board piece x y board))
    (try-collapse!)
    (spawn-piece!)))

(defn go-go-gravity!
  "Starts the gravity routine."
