refactor the login