refactor filter method