Refactor filters into functions