Added code for handling invites