Refactored ThemeFilter.filter()