fix removing while iteration