refactored login rest call