Put cost function sum argument in the right place