more complex recursion