optimizing pi program. should now be ready for the pi.