Extract "in set" logic in to function.