Extracting filtering into rules