Fixed a small bug in cost update.