Refactored p8