update to remove hasNext which is deprecated