Added grouping of adjacent iterations with the same value