Fix a grouping bug that happens if an element is found before the first grouper