Refactored p6