Updated code for the pi