Refactor isAuthorized()