Fix use of a deleted iterator value