     @rest.POST '/custom-objects', JSON.stringify(customObj), (error, response, body) ->
       if error
         deferred.reject 'Error on creating payment-info object: ' + error
-      if response.statusCode is 201
+      else if response.statusCode is 201
         deferred.resolve 'Payment info created.'
       else
         deferred.reject 'Problem on creating payment-info object: ' + body

    @rest.POST '/customers', JSON.stringify(newCustomer), (error, response, body) ->
      if error
        deferred.reject 'Error on creating customer: ' + error
      if response.statusCode is 201
        deferred.resolve JSON.parse(body).customer
      else
        deferred.reject 'Problem on creating customer: ' + body


      @processInBatches posts, callback

  processInBatches: (posts, callback, numberOfParallelRequest = 20, acc = []) =>
    current = _.take posts, numberOfParallelRequest
    Q.all(current).then (msg) =>
      messages = acc.concat(msg)
