     ruleType   = if @ruleInput.getValue().match /[0-9+]/ then "ip" else "country"
     ruleName   = @ruleNameInput.getValue()
     ruleMatch  = @ruleInput.getValue()
-    domainName = @getData().domain.domain
+    domain     = @getData().domain
+    domainName = domain.domain
     delegate   = @getDelegate()
 
-    KD.remote.api.JDomain.createProxyRule  {
-      domainName, ruleInfo:{type:ruleType, match:ruleMatch}
-    }, (err, response)->
+    domain.createProxyRule {ruleInfo:{type:ruleType, match:ruleMatch}}, (err, response)->
       if err
         return new KDNotificationView 
           title : "An error occured while performing your action. Please try again."
           type  : "top"
-      delegate.emit "newRuleCreated", {domainName:domainName, ruleName:response.Name, match:response.Match}
+      delegate.emit "newRuleCreated", 
+        domainName:domainName
+        ruleName:response.Name
+        match:response.Match
 
 
   viewAppended:->

    newAction = @actionButton.getOptions().title.toLowerCase()
    futureAction = if newAction is 'deny' then 'allow' else 'deny'

    KD.remote.api.JDomain.updateBehavior
      domainName : data.domainName
      ruleName   : data.ruleName
      behaviorInfo :
        enabled : "yes"
        action  : newAction
        index   : "0"
    , (err, response)=>
      return console.log err if err?
      @$().find("div.fw-li-view").removeClass(futureAction).addClass(newAction)
      @actionButton.setTitle futureAction


  deleteProxyRule:->
    data = @getData()

    KD.remote.api.JDomain.deleteBehavior
      domainName : data.domainName
      ruleName   : data.ruleName
    , (err, result)=>
      return console.log err if err?
      new KDNotificationView {title:"Action has been deleted from your firewall.", type:"top"}
      @destroy()


  viewAppended:->

    data = @getData()
    delegate = @getDelegate()

    KD.remote.api.JDomain.one {domainName:data.domainName}, (err, domain)->
      return console.log err if err
      domain.createRuleBehavior
        ruleName   : data.ruleName
        behaviorInfo :
          enabled : "yes"
          action  : behavior
          index   : "0"
      , (err, response)=>
        if not err
          delegate.emit "behaviorCreated", {domainName:data.domainName, ruleName:data.ruleName, action:behavior}

  pistachio:->
    """
