more pythonic way to check has_next