login refactored