Fix bug in hasNext when no result for a key is returned