Added ability to define arbitrary predicate functions