The script now works properly.