remove unused variable QueryString, move toUpperCase method outward foreach