Simplified code in pi.py