Foreigner's PID algorithm