modified pi.py