added recursion limit to cost