           priceList[currentTld] = value[0].pricing.addnewdomain[1]
       return callback priceList
 
+
   registerDomain: (domainInfo, callback)->
     #invoice option may change, but for now NoInvoice parameter is given,
     params =

# and a callback
memoize = (func) ->
  ttl = 1000
  lastQueryTime = new Date().getTime() - ttl
  memo = undefined
  (callback) ->
    current = new Date().getTime()
    if lastQueryTime <= current - ttl
      lastQueryTime = current
      func.call this, (result) ->
        memo = result
        callback memo
    return callback memo

splitDomain = (domainName) ->
  splitted =  domainName.split "."
  return {
    first: splitted[0..-2],
    extension: splitted[splitted.length-1] ? splitted.length > 1 : ""
  }

module.exports = class DomainService extends ServiceManager

      service    : "domains"
      action     : "available"
      parameters : params
    @makeRequestToResellerApi options, (err, apiResponseBody) =>
      domainKey   = domainName + "." + tld
      status      = apiResponseBody?[domainKey]?.status
      @getTldPrice tld, (price) =>
        @getDomainSuggestion domainName, tld, (suggestions)->
          callback err, status, price, suggestions

  getDomainSuggestion: (domainName, tld, callback) ->
    suggestions = []
    collectResults = race (i, item, fin) =>
      @getTldPrice splitDomain(item.domain).extension, (price) ->
        suggestions.push {domain:item.domain, price:price}
        fin()
    , ->
      callback suggestions

    domainr.search domainName, (suggestionResponse) =>
      suggestionResponse.results = (result for result in suggestionResponse.results when \
        result.availability is "available" and 
        splitDomain(result.domain).extension in availableTLDs and
        result.domain isnt domainName + "." + tld)
      for domain in suggestionResponse.results
          collectResults domain

      if suggestionResponse.results.length is 0
        callback suggestions

