Fixed the bug caused by the failure of trim_script method