prototyped updateCPTs function.  It's a bear of an algorithm