refactored login