added a check for valid URL