login method refactoring