why two calls to hasNext?