switched to using generators for iteration