Refactored p7