Refactored formatting of query parameters