Refactor predicates to use more shared code