     path          = require 'path'
     Gateblu       = require 'gateblu'
 
-
     init = =>
       config = configManager.loadConfig()
-      unless @config
+      unless config
         configManager.saveConfig()
         config = configManager.loadConfig()
 

        @gateblu.cleanup()

      process.on 'uncaughtException', (error) =>
        console.error 'uncaughtException', error
        @gateblu.cleanup()

      @gateblu.on 'gateblu:config', (config) =>


    init()
      # send this back
    @stopDevice = (device, callback=->) =>
      @gateblu.stopDevice device.uuid, callback

    @startDevice = (device, callback=->) =>
      @gateblu.startDevice device, callback

    @deleteDevice = (device, callback=->) =>
      @gateblu.deleteDevice device.uuid, device.token, callback

    @stopDevices = (callback=->) =>
      @gateblu.stopDevices callback

    return this
