 
               invite = new JInvitation data
               invite.save (err) ->
-                return callback new KodingError err  if err
+                return fin new KodingError err  if err
                 codes.push { email, code }
 
-                return queue.fin()  if noEmail
-
-                JInvitation.sendInvitationEmail client, invite, -> queue.fin()
-
-        cb = ->
-          if returnCodes
-          then callback null, codes
-          else callback()
-
-        dash queue, cb
+                return fin()  if noEmail
+
+                JInvitation.sendInvitationEmail client, invite, -> fin()
+
+
+        async.parallel queue, (err) ->
+          return callback err  if err
+          if returnCodes then callback err, codes else callback()
 
 
   # isAlreadyMember checks if the given email is already member of the given

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

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

emailsanitize = require './user/emailsanitize'


                invitation.remove()
              else
                codes.push { email, code: invitation.code, alreadyInvited: yes }
                return fin()

            isAlreadyMember group, email, (err, isMember) ->
              return fin new KodingError err  if err

              # do not send another invitation if the user is already a member
              # of the group
              return fin()  if isMember

              hash = JUser.getHash email

