added check for invalid urls