fixed potential bug, overrunning an iterator