Fixed bug with cost