correct the cost calculation