corrected use of generators, added docstrings