ability to login, refactorized code also