refactor - extract function to be used for grouping enums