Refactor filtering rules