refactor predicate pattern