Fixed while condition in iterator