Modified q3.py