Added a filter parameter to the pid function