make the script more robust.