smarter way to build the predicate