Adding predicate iteration and command rewriting