Update getCost function