refactor the filter