refactoring log on login