refactoring to applyNameFilters