Fixing issues with the script