fixed dangerous iterator