perf: Tighten (and fix) the grouping condition