fix bug in PID determination