Changed the location of the pid function