Refactored ParseQueryString method