Fix total cost calculation