fixed url building functions in utils to be more robust