Using just Java iterator