         if ++counter == batches.length
           callback(err, aliases, config.ALIASES_CACHE)
       )
+    return
   )
 
 

      db.devicesCollection.mapReduce(map, reduce, options, (err, out) ->
        for o in out
          alias = config.PARAMETERS[o.value].alias
          if not aliases[alias]?
            aliases[alias] = []
          id = String(o._id)
          if id not in aliases[alias]
            aliases[alias].push(id)

        ar.push(p)

    if isStatic
      aliases[alias] ?= []
      aliases[alias].push(k)
    else
      keys[k] = ar
