       service    : "domains"
       action     : "available"
       parameters : params
-
     @makeRequestToResellerApi options, (err, apiResponseBody) =>
-      domainKey   = "#{domainName}.#{tld}"
+      domainKey   = domainName + "." + tld
       status      = apiResponseBody?[domainKey]?.status
       @getTldPrice tld, (price) =>
-        @getDomainSuggestion domainName, "tld", (suggestions)->
-          console.log(status, price, suggestions)
+        @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) =>
-      console.log(suggestionResponse)
-      suggestions = []
-      collect = race (i, item, fin) =>
-        @getTldPrice splitDomain(item.domain).extension, (price) ->
-          console.log(splitDomain(item.domain).extension, item)
-          console.log(price)
-          suggestions.push {domain:item.domain, price:price}
-          fin()
-      , ->
-        console.log(domainName)
-        console.log("exit:", suggestions)
-        callback suggestions
-      console.log("asdsad:"+domainName + "." + tld)
       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
-          collect domain
+          collectResults domain
+
       if suggestionResponse.results.length is 0
         callback suggestions
 

          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 = 0
  memo = undefined
  (callback) ->
    current = new Date().getTime()
    if lastQueryTime < current - ttl
      lastQueryTime = current
      func.call this, (result) ->
        memo = result
        callback memo
      return
    return callback memo

splitDomain = (domainName) ->
  splitted =  domainName.split "."
  return {
    first: splitted[0],
    extension: if splitted.length > 1 then splitted[1..].join "." else ""
  }

module.exports = class DomainService extends ServiceManager
