Change hasNext logic back to the correct version.