fix bug in query re measure property
simplify code a bit, and some performance tweaks