fix the query string building