Refactored authorization route checking code