fixed bugs in script