fix bug in cost