fix iterator bugs