login flow refactoring

refactored login flow