Fine tune the grouping algorithm