Fixing deep recursion