maybe move the `Iterator<?> i = files.iterator();` down from above and avoid duplication