Unified functions in generate_url()