added handling for invalid urls