login refactoring