Add grouping functionality