refinining login and authentication flow a little