Refactor login bits