Improved url generation