AppleScript crashing Photoshop CS5

I’ve gotten the following script to work on Photoshop CS5.5, Photoshop CC 2014 and Photoshop CC 2017. It crashes with Photoshop CS5. Any ideas how to fix this would be greatly appreciated. Thanks!

-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------

--HOW THIS SCRIPT WORKS:
--This applescript droplet runs whenever a file is dropped onto it. 
--First, it creates a backup folder on the user's desktop called "Backups of Images"
--Then, it makes a backup copy to the user's desktop just in case the layered version is needed
--It opens each dropped file in photoshop where it is converted to CMYK
--It attempts to save and close the file
--It provides a bug fix for the overwriting save problem when using Photoshop CS5 or CS5.5 on newer operating systems
--It displays a dialog to the user if there were any problems
--It displays a success dialog to the user if everything went well

-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------


on open droppedfiles
	with timeout of 1500 seconds
		
		---------------------------------------------------------------------------------------------------
		-- CREATING AN EMPTY LIST TO ADD PROBLEM FILES TO
		---------------------------------------------------------------------------------------------------
		
		set problem_list to {}
		set layered_list to {}
		
		
		---------------------------------------------------------------------------------------------------
		-- CREATING BACKUP FOLDER IF IT DOESN'T EXIST
		---------------------------------------------------------------------------------------------------
		
		repeat with afile in droppedfiles
			
			--SETTING THE PATH TO THE DESKTOP
			tell application "Finder"
				set desktop_folder to path to desktop as string
			end tell
			
			
			--CREATING BACKUP FOLDER ON THE DESKTOP IF IT DOESN'T EXIST YET
			if not my CheckForFolder(desktop_folder & "Backups of Images:") then
				tell application "Finder"
					set backup_folder to make new folder at folder desktop_folder with properties {name:"Backups of Images"}
				end tell
			end if
			set backup_folder to desktop_folder & "Backups of Images:" as string
			
			
			-------------------------------------------------------------------------------------
			--BACKING UP THE IMAGES BEFORE PROCESSING
			-------------------------------------------------------------------------------------
			
			tell application "Finder"
				set file_ext to name extension of afile
				set filename to name of afile
				duplicate afile to alias backup_folder with replacing
			end tell
			
			
			-------------------------------------------------------------------------------------
			--CHANGING THE COLOR MODE TO RGB IN PHOTOSHOP
			-------------------------------------------------------------------------------------
			
			tell application "Adobe Photoshop CC 2017"
				activate
				set display dialogs to never
				open afile showing dialogs never
				
				tell current document
					
					--Adding the image's filename to a warning list if the image has multiple layers
					set layer_count to (count of layers) as string
					if layer_count is greater than 1 then
						set layered_list to layered_list & "¢ " & filename & return
						
						
						--Doing the rest of the processing if the image is flattened
					else
						
						try
							
							--Changing color mode to CMYK
							change mode to CMYK
							
							
							-------------------------------------------------------------------------------------
							--SAVING THE IMAGE
							-------------------------------------------------------------------------------------
							
							--Trying to save
							try
								if file_ext contains "tif" or file_ext contains "jpg" or file_ext contains "jpeg" or file_ext contains "png" then
									save
								else
									save in file file_path as TIFF appending lowercase extension without copying
								end if
								
								
								--This is the bug fix that saves a copy of the image
								--Photoshop CS5.5 on newer operating systems throws an error when overwriting files on a server with an smb connection 
								--Apple says this is Adobe's fault. Adobe says this is Apple's fault. 
							on error
								
								--Trimming the extension of the filename so we can add _1, _2, _3 to the end of the filename
								tell application "Finder"
									set old_delims to AppleScript's text item delimiters
									set AppleScript's text item delimiters to "." & file_ext
									set path_without_extension to first text item of file_path
								end tell
								
								--Adding _1, _2, _3, etc. to the end of the filename to save a copy
								repeat
									set the name_increment to 1
									set revised_file_path to path_without_extension & "_" & (name_increment as string) & "." & file_ext as string
									try
										if file_ext contains "tif" then
											save in file revised_file_path as TIFF appending lowercase extension without copying
										else if file_ext contains "jpg" or file_ext contains "jpeg" then
											save in file revised_file_path as JPEG appending lowercase extension without copying
										else if file_ext contains "png" then
											save in file revised_file_path as PNG appending lowercase extension without copying
										else
											save in file revised_file_path as TIFF appending lowercase extension without copying
										end if
										exit repeat
									on error
										set revised_file_path to path_without_extension & "_" & (name_increment as string) & "." & file_ext as string
										save in file revised_file_path
										
										
										--Using the finder to rename the file to the original name
										tell application "Finder"
											set revised_file to revised_file_path as alias
											try
												set name of revised_file to filename
											end try
										end tell
									end try
									
								end repeat
								
								--Resetting applescript's text item delimiters
								tell application "Finder" to set AppleScript's text item delimiters to old_delims
								
							end try
							
							
							--Closing the document
							close saving no
							
						on error
							set problem_list to problem_list & "¢ " & filename & return
						end try
					end if
				end tell
			end tell
		end repeat
		
		
		---------------------------------------------------------------------------------------------------
		-- DISPLAYING AN ERROR OR SUCCESS DIALOG TO THE USER
		---------------------------------------------------------------------------------------------------
		
		--Display error message if there were any problems
		if problem_list is not {} and layered_list is {} then
			tell application "SystemUIServer"
				display dialog "THERE WAS A PROBLEM WITH SOME IMAGES:" & return & "The following files had a problem and have been left open in Photoshop. Please try dropping them on the script again:" & return & return & problem_list & return & "Images not in the above list processed successfully. If needed, the originals are in a folder called 'Backups of Images' on your desktop." as string with icon caution giving up after 900
			end tell
			
			--Display error/layered message if there were any problems and there were layered images
		else if problem_list is not {} and layered_list is not {} then
			tell application "SystemUIServer"
				display dialog "ATTENTION:" & return & return & "THERE WAS A PROBLEM WITH SOME IMAGES:" & return & "The following files had a problem and have been left open in Photoshop. Please try dropping them on the script again:" & "--------------------" & return & return & problem_list & return & return & "IMAGES WERE LAYERED:" & return & "The color mode was not changed on the following layered images because changing the color mode of layered images can have unexpected effects:" & return & return & layered_list & return & return & "Images not in either of the lists were processed successfully. If needed, the originals are in a folder called 'Backups of Images' on your desktop." as string with icon stop giving up after 900
			end tell
			
			
			--Display layered message if there were layered images
		else if problem_list is {} and layered_list is not {} then
			tell application "SystemUIServer"
				display dialog "ATTENTION: IMAGES WERE LAYERED" & return & "The color mode was not changed on the following layered images because changing the color mode of layered images can have unexpected effects:" & return & return & layered_list & return & "Any images not in the above list processed successfully. If needed, the originals are in a folder called 'Backups of Images' on your desktop." with icon stop giving up after 900
			end tell
			
			--Display success message if everything is good
		else
			tell application "SystemUIServer"
				display dialog "SUCCESS!" & return & "All the files have been successfully converted to CMYK." & return & return & "If needed, the originals are in a folder called 'Backups of Images' on your desktop." with icon note giving up after 900 -->Will display the success message to the user for 15 minutes or until ok is clicked
			end tell
		end if
		
		
	end timeout
end open

---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------

--FUNCTION TO CHECK IF A FOLDER EXISTS
on CheckForFolder(thisFolder)
	tell application "Finder"
		return (exists folder thisFolder)
	end tell
end CheckForFolder