Refactoring directory filtering