recursion and pruning