grouping rewritten