Fix when removing script after a ping, check if script element exists