fix iterator cast issue