Refactoring of authorization system