                 invitation.remove()
               else
                 codes.push { email, code: invitation.code, alreadyInvited: yes }
-                return queue.fin()
+                return fin()
 
             isAlreadyMember group, email, (err, isMember) ->
-              return callback new KodingError err  if err
+              return fin new KodingError err  if err
 
               # do not send another invitation if the user is already a member
               # of the group
-              return queue.fin()  if isMember
+              return fin()  if isMember
 
               hash = JUser.getHash email
 

Tracker     = require './tracker'
KodingError = require '../error'
{ extend }  = require 'underscore'

{ protocol, hostname } = KONFIG
{ secure, signature, dash } = Bongo

emailsanitize = require './user/emailsanitize'


        return callback new KodingError err                   if err
        return callback new KodingError 'group doesnt exist'  if not group


        queue = invitations.map (invitation) -> (fin) ->

          { email, firstName, lastName, role } = invitation

          JInvitation.one { email, groupName }, (err, invitation) ->
            return fin new KodingError err  if err

            # do not send another invitation if the user is already invited
            # before
