Make the script more bullet-proof.