     @rest.POST "/customers/#{customer.id}", JSON.stringify(data), (error, response, body) ->
       if error
         deferred.reject 'Error on linking customer with group: ' + error
-      if response.statusCode is 200
+      else if response.statusCode is 200
         deferred.resolve 'Customer linked to customer group.'
       else
         deferred.reject 'Problem on linking customer with group: ' + body

    @rest.POST "/customers/#{customer.id}", JSON.stringify(data), (error, response, body) ->
      if error
        deferred.reject 'Error on adding address: ' + error
      if response.statusCode is 200
        deferred.resolve JSON.parse(body)
      else
        deferred.reject 'Problem on adding address: ' + body

          @createPaymentInfo(customer, paymentInfo)
          @linkCustomerIntoGroup(customer, newCustomer.customerGroup)
        ]
        Q.all(posts).fail (msg) ->
          deferred.reject msg
        .then (msg) ->
          deferred.resolve "Customer created."

    deferred.promise
