Fixed the iterator for Java