Modified code to do pi testing