Refactor `pf` implementation