more refactoring of the filter