invitation sorted for internal and external, code broken down into different functions and redirected properly with flash notices