fix subgroups start and end indexes.