optimize pump.py