implemented invitation logic