Refactor chat filtering