Added logic to format query with querystring params and default params.