Added the cost method