Refactor latex url building