Hi Felipe,
I believe the issue is with this line:
wixData.remove(collectionName, item._id)
wixData.remove returns a promise, so you will have to await until its resolved to make sure the items were completely removed before proceeding to add items in the next function.