getCost function

Extract cost values