When removing a vertex group, the next groups were not reassigned because the loop upper limit was wrong.