Fix iterator scope