Improved row grouping