Refactor and simplify

- Extract shared filter logic