refactor code out into reusable functions
refactor accept_invite function into a class so it can be shared more easily