collapsing repeating patterns