Refactored login structure