Add PID middleware