refactor filters logic