fix bug with query string being created incorrectly