Tidier grouping logic.