Fix remainder grouping bug