Refactor login model