refactor p5