Minor Refactoring of login