Refactor out role determination logic