       list = for {file} in statements.children()
                file.basename
 
-    response:
-      status: 'ok'
-      'statement.list': list
-
-  statement_read: (data) ->
+    respond response:
+              status: 'ok'
+              'statement.list': list
+
+  statement_read: (data, respond) ->
     unless data
-      return response:
-               status: 'error'
-               error: "statement id required"
+      respond response:
+                status: 'error'
+                error: "statement id required"
+      return
 
     statement = Dir.profile.child('statements').child(data)
 
     if statement.exists()
-      response:
-        status: 'ok'
-        'statement.read': statement.read()
-    else
-      response:
-        status: 'error'
-        error: "No statement found with id=#{data}"
-
-  job_stop: (data) ->
+      respond response:
+                status: 'ok'
+                'statement.read': statement.read()
+    else
+      respond response:
+                status: 'error'
+                error: "No statement found with id=#{data}"
+
+  job_stop: (data, respond) ->
     logger.info 'Got request to stop job, shutting down'
 
     # job didn't finish, so it failed
     @job.fail 504, 'timeout.quit' unless @job.done
 
-    response:
-      status: 'ok'
-
-  xul_quit: (data) ->
+    respond response:
+              status: 'ok'
+
+  xul_quit: (data, resopnd) ->
     setTimeout (-> goQuitApplication()), 1000
 
-    response:
-      status: 'ok'
-
-  page_dump: (data) ->
+    respond response:
+              status: 'ok'
+
+  page_dump: (data, respond) ->
     try
-      response:
-        status: 'ok'
-        'page.dump': @job.player.page.dump()
+      respond response:
+                status: 'ok'
+                'page.dump': @job.player.page.dump()
 
     catch e
       logger.error 'page.dump: ', e
-      response:
-        status: 'error'
-        error: e.toString()
-
-  eval: (data) ->
+      respond response:
+                status: 'error'
+                error: e.toString()
+
+  eval: (data, respond) ->
     try
       script = data.script
       @scope ||=


      @scope._ = result

      response:
        status: 'ok'
        eval: inspect(result, undefined, undefined, color: data.color)

    catch e
      logger.error 'eval: error: ', e
      response:
        status: 'error'
        error: e.toString()


module.exports = Controller

    catch e
      logger.error 'job.start: ', e

    respond response:
              status: 'ok'

  job_resume: (data, respond) ->
    if @job
      try
        @job.resume data.creds
        respond response:
                  status: 'ok'

      catch e
        respond response:
                  status: 'error'
                  error: e.toString()

    else
      respond response:
                status: 'error'
                error: "No running jobs"

  job_status: (data, respond) ->
    unless @job
      respond response:
                status: 'error'
                error: "No running jobs"
    else
      respond response:
                status: 'ok'
                'job.status':
                  status: @job.status
                  result: @job.result
                  data: @job.data
                  jobid: @job.jobid
                  fid: @job.fid
                  completed: @job.done
                  cookies: cookies.dump()
                  timestamp: new Date().getTime()
                  version: @job.version

  statement_list: (data, respond) ->
    statements = Dir.profile.child 'statements'
    list = []

