Fixing url detection logic