Refactor to use a filter