modified extract.py