small refactor of the login method