HELP! Where is my logic? Items not passing after a clause.

This script id part of a bigger script, but it takes a file BH70GB00332CY1GO.PSD

and it check it against a line in CSV file

BH70GB00332CY1GO.PSD,BH70GB00332CY1GO,Crystal Flower Jewellery Set,15

It then uses exiftool to append it to the files meta data,
After that it adds a tick to the CSV so I know that the image has been shot.
As far as that is concerned that works.

Where it doesn’t work are secondary images, these are marked _2, _3, 4 etc.

With secondary images it does not require a tick to be put on the CSV but it does require the metadata to be added.

How could I get this to work?
I’ve included the result to show how it is working.

I didn’t write this script I had help from the forums. But I have done my best to understand the logic. But I still can’t see where it goes wrong. All I do know is that I think something goes wrong on this line

if not b and aRowinSkulist starts with WholenameComma or b and (aRowinSkulist starts with sku_only or aRowinSkulist starts with "✔," & sku_only) then -- found
on findNameInCsv(f) -- search the exact name from the beginning of each line ***
	set {tid, text item delimiters} to {text item delimiters, {":"}}
	set tName to last text item of f -- get the filename
	log "f filepath; " & f
	log "tName; " & tName
	set text item delimiters to "."
	set thisExt to last text item of tName -- get name extension
	log "thisExt; " & thisExt
	set text item delimiters to tid
	
	if thisExt is in extension_list then
		set tc to (count thisExt) + 2
		log "tc " & tc
		set suffix to text -(tc + 1) thru -tc of tName -- get last 3 characters before name extension--> _02
		log "suffix Route A; " & suffix
	else -- no extension
		set suffix to text -2 thru -1 of tName -- get last 3 characters --> _02
		log "suffix Route B; " & suffix
	end if
	
	tell suffix to set b to it starts with "_" and (text 2 is in "23456789")
	log "b Route A; " & b
	
	try
		if b then set sku_only to text 1 thru 16 of tName -- the begining 16 digits, I presume the first 16 characters in the nameon error
		set b to false
		log "b Route B; " & b
		log "Sku_only; " & sku_only
		
	end try
	
	
	
	set WholenameComma to tName & ","
	log "WholenameComma; " & WholenameComma
	set tc to count o's csvText
	repeat with i from 1 to tc
		set aRowinSkulist to item i of o's csvText
		log "aRowinSkulist; " & aRowinSkulist
		
		if not b and aRowinSkulist starts with WholenameComma or b and (aRowinSkulist starts with sku_only or aRowinSkulist starts with "✔," & sku_only) then -- found
			set x to "" -- Not sure of its purpose
			
			if not b then set item i of o's csvText to "✔," & aRowinSkulist
			set text item delimiters to {","}
			try
				set headline2 to text item 2 of aRowinSkulist --get original Name
				set x3 to (text item 3 of aRowinSkulist) & "ALTERNATIVE CODE :_" --get alternative Sku 
				set keyword4 to text item 4 of aRowinSkulist -- get the keyword 
				try
					set WeekNumber5 to text item 6 of aRowinSkulist --get AIR OR SEA RECORD 
				on error
					set WeekNumber5 to ""
				end try
			end try
			set text item delimiters to tid
			-- exiftool add the keywords to EXIF 
			
			if keyword4 is not "" then do shell script "/usr/bin/exiftool -P -overwrite_original_in_place -keywords+=" & (quoted form of keyword4) & " -headline=" & (quoted form of headline2) & " -source=" & (quoted form of WeekNumber5) & " " & quoted form of POSIX path of f
			
			return (not b)
		end if
	end repeat
	return false
end findNameInCsv

THE RESULT IN PART BELOW

tell application "Finder"
	set label index of document file "StudioD:Users:StudioD:Pictures:CompletedFolders:BHS_WK15_PSD:BH70GB00332CY1GO.PSD" to 6
		--> 6
end tell
(*f filepath; StudioD:Users:StudioD:Pictures:CompletedFolders:BHS_WK15_PSD:BH70GB00332CY1GO.PSD*)
(*tName; BH70GB00332CY1GO.PSD*)
(*thisExt; PSD*)
(*tc 5*)
(*suffix Route A; GO*)
(*b Route A; false*)
(*b Route B; false*)
(*WholenameComma; BH70GB00332CY1GO.PSD,*)
(*aRowinSkulist; BH70ER05545BU7RH.PSD,BH70ER05545BU7RH,,Blue Diamond Drop Earring,15*)
(*aRowinSkulist; BH70JM02206RD1RH.PSD,BH70JM02206RD1RH,,Red Flower Jewellery Set,15*)
(*aRowinSkulist; BH70NW05351CY2RH.PSD,BH70NW05351CY2RH,,Pearl And Sparkle Bead Necklace,15*)
(*aRowinSkulist; BH70GB00332CY1GO.PSD,BH70GB00332CY1GO,,Crystal Flower Jewellery Set,15*)
tell current application
	do shell script "/usr/bin/exiftool -P -overwrite_original_in_place -keywords+='Crystal Flower Jewellery Set' -headline='BH70GB00332CY1GO' -source='' '/Users/StudioD/Pictures/CompletedFolders/BHS_WK15_PSD/BH70GB00332CY1GO.PSD'"
		--> "    1 image files updated"
end tell
tell application "Finder"
	get document file "BH70GB00332CY1GO_2.PSD" of folder "BHS_WK15_PSD" of folder "CompletedFolders" of folder "Pictures" of folder "StudioD" of folder "Users" of startup disk
		--> "StudioD:Users:StudioD:Pictures:CompletedFolders:BHS_WK15_PSD:BH70GB00332CY1GO_2.PSD"
end tell
tell application "Image Events"
	open file "StudioD:Users:StudioD:Pictures:CompletedFolders:BHS_WK15_PSD:BH70GB00332CY1GO_2.PSD"
		--> image "BH70GB00332CY1GO_2.PSD"
	get dimensions of image "BH70GB00332CY1GO_2.PSD"
		--> {1631, 2217}
	close image "BH70GB00332CY1GO_2.PSD"
end tell
tell application "Finder"
	set label index of document file "StudioD:Users:StudioD:Pictures:CompletedFolders:BHS_WK15_PSD:BH70GB00332CY1GO_2.PSD" to 6
		--> 6
end tell
(*f filepath; StudioD:Users:StudioD:Pictures:CompletedFolders:BHS_WK15_PSD:BH70GB00332CY1GO_2.PSD*)
(*tName; BH70GB00332CY1GO_2.PSD*)
(*thisExt; PSD*)
(*tc 5*)
(*suffix Route A; _2*)
(*b Route A; true*)
(*b Route B; false*)
(*Sku_only; BH70GB00332CY1GO*)
(*WholenameComma; BH70GB00332CY1GO_2.PSD,*)
(*aRowinSkulist; BH70ER05545BU7RH.PSD,BH70ER05545BU7RH,,Blue Diamond Drop Earring,15*)
(*aRowinSkulist; BH70JM02206RD1RH.PSD,BH70JM02206RD1RH,,Red Flower Jewellery Set,15*)
(*aRowinSkulist; BH70NW05351CY2RH.PSD,BH70NW05351CY2RH,,Pearl And Sparkle Bead Necklace,15*)
(*aRowinSkulist; ✔,BH70GB00332CY1GO.PSD,BH70GB00332CY1GO,,Crystal Flower Jewellery Set,15*)
(*aRowinSkulist; ✔,BH70NW05344CY1GO.PSD,BH70NW05344CY1GO,,Gold Rhinestone V Necklace,15*)
(*aRowinSkulist; ✔,BH70NW05344CY1SV.PSD,BH70NW05344CY1SV,,Silver Rhinestone V Necklace,15*)
(*aRowinSkulist; ✔,BH70JM02199RD1SH.PSD,BH70JM02199RD1SH,,Red Facet and Shell Multipack,15*)

I’ve moved the try statement and made it a little clearer (I hope), I moved it down, previously it was in the line above set WholenameComma…

This now works a little better as it will add the exif info to the file, however it doesn’t add a tick on the non suffix versions?

set WholenameComma to tName & ","
	
	try
		if suffix begins with "_" then set WholenameComma to (text 1 thru 16 of tName & ".PSD,") -- the begining 16 digits, I presume the first 16 characters in the nameon error
		set b to true
		log "b Route B; " & b
		log "Sku_only; " & WholenameComma
	end try
	
	log "WholenameComma; " & WholenameComma