Change the cost function