cpm logic