refactoring over login logic.