more query rewrite logistic added