fix formatting of query