refactor filter implementation