Refactor filter impl