Refactor to filter pattern