item = updatedItem;
This is just setting the value of the iteration variable, it doesn't change anything about mutableArrayOfSet
.
What you should do is to create a set of changes while you iterate and then save those changes into the source object after the iteration is complete.