add helper function for the recursion
prune unnecessary files