Fix filtering logic.