Changed the logic for finding out the PID