complete query string generation