add selfcost in addition to total cost of function