Refactor login.