fixed the logic to determine hasNothing and hasNoMore