I don't think it is a good idea to remove items from the packages list while iterating over it.