Refactoring authorization layer