fix calculation total_cost