Do not try to iterate a list as it gets emptied.