            [:a {:href (str "/boxes/" idx "/down")} "Down"]
            [:iframe {:src url}]]))
 
-(defn swap [v i1 i2] 
-  (assoc v i2 (v i1) i1 (v i2)))
+(defn swap [v i1 i2]
+  (let [i1' (mod i1 (count v))
+        i2' (mod i2 (count v))
+        i1'' (min i1' i2')
+        i2'' (max i1' i2')]
+    (assoc v i2'' (v i1'') i1'' (v i2''))))
 
 (defn push-box-up [idx]
    (reset! boxes (swap @boxes (dec idx) idx)))

            [hiccup.core :as h]
            [ring.util.response :as rr]
            [org.httpkit.server :as hk]))

(def boxes (atom ["/1" "/2"]))


           (GET "/down" [] (do 
                             (push-box-down index)
                             (rr/redirect "/boxes"))))
  (GET "/boxes" []  (page (map-indexed draw-box @boxes)))
  (GET "/:number" [number] (h/html [:h1 {:class "number"} number]))
  (GET "/" [] (rr/redirect "/boxes"))
  (route/not-found (h/html [:h1 "Dumbass"])))
