fixing bugs in some of the scripts