corrected looping in determineCPE()