tweak scripts to be more robust