adding flags for unsorted predicates and termination check