refactored authorize call