Use querystring lib and delete generateQuerystring() function