More efficient queries for z3