login refactor