Solved and refactored P3, pseudocode P4