update: serialize totalCost first.