refactoring and login