Improve the stability of scripts