Improved url detection