finished row grouping code.