Modified P4 to improve code for readability.