updated recursion