 
     run_context.cli = cli = bind_cli run_context
 
-    error = (message) ->
-      $pre = $ '<pre class="error"/>'
-      $pre.text message
-      run_context.output $pre
-
-    result_handlers =[
-      ignored,
-      handle_cli_cmd,
-      handle_renderable,
-      handle_lead_node,
-      handle_any_object
-    ]
-
-    display_object = (object) ->
-      for handler in result_handlers
-        return if handler.call run_context, object
-
+    run_in_context run_context, string
+
+    scroll_to_result $top
+
+    output_cell
+
+  run_in_context = (run_context, string) ->
     try
       compiled = CoffeeScript.compile(string, bare: true) + "\n//@ sourceURL=console-coffeescript.js"
     catch e
       if e instanceof SyntaxError
-        error "Syntax Error: #{e.message} at #{e.location.first_line + 1}:#{e.location.first_column + 1}"
+        run_context.error "Syntax Error: #{e.message} at #{e.location.first_line + 1}:#{e.location.first_column + 1}"
       else
         run_context.handle_exception e, compiled
 

        `with (run_context.cli) { with (run_context.functions) { with (run_context.vars) {`
        result = eval compiled
        `}}}`
        display_object result
      catch e
        run_context.handle_exception e, compiled

      scroll_to_result $top

    output_cell

  opening_run_context = null


      setTimeout ->
        $('html, body').scrollTop top
      , 10

    result_handlers =[
      ignored,
      handle_cli_cmd,
      handle_renderable,
      handle_lead_node,
      handle_any_object
    ]

    output = ($target) ->
      (output) ->
