Fix for "Collection was modified" error