gen.py modified