Fixing issues in script