Refactored authorization