implemented hasnext()