begin change cost function