    [message-form]])
 
 (defn join-room-view []
-  (let [this-room (atom (random-four-characters))
+  (let [this-room        (atom (random-four-characters))
         change-location #(set! (.-location js/window) (str "#/room/" @this-room))]
     [:div
-     [:p [:div
-          [:button {:on-click change-location
-                    :type "submit"}
-           "New Room"]]]
-
-     [:p [:div
-          [:input {:placeholder "Room Name"
-                   :type "text"
-                   :on-change #(reset! this-room (-> % .-target .-value))}]
-          [:button {:type "submit"
-                    :on-click change-location}
-           "Join Room"]]]]))
+     [:input {:placeholder "Room Name"
+              :type "text"
+              :on-change #(reset! this-room (-> % .-target .-value))}]
+     [:button {:type "submit"
+               :on-click change-location}
+      "Join Room"]
+     [:button {:on-click change-location
+               :type "submit"}
+      "Random Room"]]))
 
 (defn home-page []
-  [:div
-   [:div {:class "container"}
-    [:div {:class "page-header"}
-     [:h2 "Minimal Chat"]]
+  (let [chat-room (subscribe [:current-chat-room])
+        messages  (subscribe [:chat-room-messages])]
+    [:div
+     [:div.container
+      [:div.page-header
+       [:h2 "Minimal Chat"]]
 
-    (if @chat-room
-      [on-going-chat]
-      [join-room-view])
+      (if @chat-room
+        [on-going-chat]
+        [join-room-view])
 
-    [:div [:br] [:br] [:br]
-     "STATE!!!!"
-     [:div "Messages: " (pr-str @messages)]]]])
+      [:div [:br] [:br] [:br]
+       "STATE!!!!"
+       [:div "Messages: " (pr-str @messages)]]]]))
 
 (defn current-page []
   [:div [(session/get :current-page)]])
 
-;; -------------------------
-;; Routes
+;; -- Routes and History ----
 
 (secretary/defroute "/" []
-  (reset! chat-room nil)
+  (dispatch [:exit-chat-room])
   (session/put! :current-page #'home-page))
 
-(secretary/defroute "/room/:id" {:as params}
-  (when (not= @chat-room (:id params))
-    (join-room (:id params)))
+(secretary/defroute "/room/:id" [id]
+  (dispatch [:join-chat-room id])
   (session/put! :current-page #'home-page))
-
-;; -------------------------
-;; History
-;; must be called after routes have been defined
 
 (defn hook-browser-navigation! []
   (doto (History.)

             :on-change #(dispatch [:set-username-input (-> % .-target .-value)])}]))

(defn message-form []
  (let [message  (reagent/atom "")
        username (subscribe [:username-input])]
    [:form {:on-submit (fn [e]
                         (.preventDefault e)
                         (firebase-swap! @fb-messages conj [@username @message]))}
     [:input {:type "text"
              :on-change #(reset! message (-> % .-target .-value))}]
     [:button {:type "submit"} "Send"]]))


  ;; mount root
  (reagent/render-component [current-page] (.getElementById js/document "app")))

