pph script refactor