updated generator functions in optimizedgenerator.py