refactored login to be more robust