   (let [query-channel (http/get query-path {:channel (chan 1 (map :body))})
         sparql-results (sparql-results-channel)]
     (go
-      (reset! loading? true)
+      (swap! app-state #(assoc % :loading? true))
       (let [query (render-template (<! query-channel) :data data)]
         ;(.log js/console query)
         (>! sparql-results (<! (sparql-query-channel query))))
-      (reset! loading? false))
+      (swap! app-state #(assoc % :loading? false)))
     sparql-results))
 
 (defn sparql-autocomplete

  }
  ORDER BY DESC(?order)
  LIMIT 10")

; ----- Public vars -----

(def loading? (atom false))

; ----- Public functions -----


(defn wrap-load
  [input-channel output-channel]
  (go
    (swap! app-state #(assoc % :loading? true))
    (>! output-channel (<! input-channel))
    (swap! app-state #(assoc % :loading? false)))
  output-channel)

(defn sparql-query
