fixed some bugs on runScript