Added calculation of cost_total