Extracting generate_url method