adding iterator hasnext() check, fixes issue #75