added robust predicates
revised to compile on win