Fix groupByMatchingIds