changed check  for invalid URLs