generic filter by pair of values