simulating recursion