fix bugs in scripts