Use iterator for safe modification of lists