 
   return owner
 
-setOwnerOfStack = (stack, newOwnerId, oldOwner) ->
+
+setOwnerOfStack = (stack, newOwner, oldOwner, group) ->
+
+  newOwnerId = newOwner.getId()
 
   stack.unuseStackTemplate (err) ->
     log 'Failed to mark as unused stack:', err  if err


  # Update machine ownership to the admin who kicked the member
  machine.addUsers {
    targets: [ user ], asOwner: yes, sudo: yes, group: group.slug
  }, (err) ->
    log 'Failed to change ownership of machine:', err  if err


      updateStacks {
        stacks   : memberStacks
        oldOwner : memberJUser.getAt 'username'
        group    : group.slug
        requester, reason
      }
      next()

