refactoring filter a bit