refactored calculateCPP