Reorganise grouping of patterns