improved recursion file