one more pass on query formatting