Refactor filters logic