modified generate.py