using iterator instead of iterable saves ram