Fixed small mistake in iterative version