Refactored url building