Refactor login service