     newsletter
     # is group creator already a member
     alreadyMember }              = body
-  { JUser, JGroup, JInvitation } = koding.models
   body.groupName                 = slug
   # needed for JUser.login to know that it is a regular login or group creation
   body.groupIsBeingCreated       = yes
 
   clientId                       = getClientId req, res
+
+  { JUser, JGroup, JInvitation, JTeamInvitation } = koding.models
 
   return handleClientIdNotFound res, req  unless clientId
 

  alreadyMember       = alreadyMember is 'true'

  queue = [

    ->
      koding.fetchClient clientId, context, (client_) ->


        -> createInvitations client, invitees, (err) ->
            console.error 'Err while creating invitations', err  if err
            queue.fin()
        ->
          if not teamAccessCode
            queue.fin()
          else
            JTeamInvitation.byCode teamAccessCode, (err, invitation) ->
              if err or not invitation
                queue.fin()
              else
                invitation.markAsUsed (err) ->
                  console.error err
                  queue.fin()
      ]

      dash queue, (err) ->
