better grouping of matches