code for hasNext
close #18