minor refactoring of login