refactored, with role mapping