refactoring login