   [env form]
   (when-not (running? env) (throw (Exception. "Server not running")))
   (let [{session :session} @env
-        result (doall (nrepl/message session {:op "eval" :code (str form)}))]
+        {browser-repl-env :browser-repl-env} @env
+        ; result (doall (nrepl/message session {:op "eval" :code (str form)}))
+        result (cemerick.piggieback/cljs-eval browser-repl-env form :verbose true)]
     result))
 
 (defn start-browser-repl-default
   [env]
-  (let [port (:client-port env)]
-   (cljs-eval env `(do (require 'cljs.repl.browser)
-                  (cemerick.piggieback/cljs-repl
-                   :repl-env (cljs.repl.browser/repl-env :port ~port)))))
-  (swap! env #(assoc % :browser-repl-enabled true)))
+  (let [port (:client-port @env)
+        browser-repl-env (cljs.repl.browser/repl-env :port port)]
+    (cemerick.piggieback/cljs-repl :repl-env browser-repl-env)
+    (swap! env #(assoc % :browser-repl-enabled true))
+    (swap! env #(assoc % :browser-repl-env browser-repl-env))))
 
 (defn start-browser-repl
   [env]

(ns cljs-workspace.nrepl-backlink
; (ns user
  (:require [clojure.tools.nrepl.server :as server]
            [clojure.tools.nrepl :as nrepl]
            [cider.nrepl]
            [cemerick.piggieback]))

; (defonce server (server/start-server :port 7888))

(def default-env {:port 7888
                  :client-port 9000
                  :server nil
                  :conn nil
                  :session nil
                  :browser-repl-enabled false})

(defn- reset-env
  [env]


(defn stop-browser-repl
  [env]
  (when (:browser-repl-enabled env)
    (cljs-eval env :cljs/quit)
    (swap! env #(assoc % :browser-repl-enabled false))))


(defn stop
