refactored and added a new filter for determining which directories to walk