Add anonymous function to deal with maximum recursion deepth