latest code with invite code functionality