Refactored p5