Refactor the URL building