Fix bug with iterator not being incremented