refactored code to construct url as function