fix iterator misuse