Added new functions to fix URL formatting error for more complicated queries