Improved: URL builder algorithm