Getting numbers to remove a dynamic range of columns

Im trying to get AppleScript to sort the table and keep only the first 8 columns, the total number of columns often varies each use, as well as the column names.
This script gets it done but when there’s less columns it throws errors as it runs out of columns to remove when the amount of columns is less than the repeat amount.

Is there a way to tell it to select column 9 to the last column and remove the selection?
Or any better way of handling this?

tell application “Numbers”
tell document 1 to tell sheet 1 to tell table 1
sort by column 1 direction ascending

	repeat 22 times
		remove column 9
	end repeat
end tell

end tell


tell application "Numbers"
	activate
	tell document 1 to tell sheet 1 to tell table 1
		sort by column 1 direction ascending
		repeat 22 times
			try
				remove column 9
			on error
				exit repeat
			end try
		end repeat
	end tell
end tell

Or:


tell application "Numbers"
	activate
	tell table 1 of sheet 1 of document 1
		set columnCount to (count columns)
		if (columnCount > 8) then remove (columns 9 thru columnCount)
		sort by column 1 direction ascending
	end tell
end tell

Thanks for the help guys, solved it for me