revised code for cpt calculation