Refactoring the url function