refactor how query string is handled