Refactoring login 1