creates cost function
no change