Fine tune grouping algorithm