Apple Script no longer working with BigSur

I had this script for changing the printing paper size and saving the document pass-word protected. It was working perfectly before the software update to BigSur
The problem seems to be the line “click pop up button 3”. It does not recognize the button even when it is opening the correct window which has the button I want to click. Could you please help me figuring out why it is not recognizing the pop up button?

set FixedPassword to "nocopy"

set VarPassword to "fibonacci"

set outpath to "/Users/E1S0.pdf"

set SaveFolder to "/Users/Exam1"

set FileName to "E1S0" & " " & "(Password" & " - " & VarPassword & ").pdf"


tell application "Preview"
	activate
	open outpath
end tell


activate application "Preview"
tell application "System Events"
	tell process "Preview"
		keystroke "p" using command down
		delay 0.5
		tell front window
			repeat until exists sheet 1
				delay 10
			end repeat
			tell sheet 1
				click pop up button 3
				click menu item "My Customized Size" of menu 1 of pop up button 3
				click menu button "PDF"
				repeat until exists menu 1 of menu button "PDF"
					delay 0.02
				end repeat
				click menu item "Save as PDF" of menu 1 of menu button "PDF"
				
			end tell
		end tell
		
		-- Make sure the save dialog is visible
		repeat until exists sheet 1 of sheet 1 of front window
			delay 0.2
		end repeat
		
		tell sheet 1 of sheet 1 of front window
			click button "Security Options..."
		end tell
		
		tell window "PDF Security Options"
			set selected to true
			set focused to true
			(* click the checkbox to on *)
			-- NOTE: for some reason there is a delay of about 6 seconds here, I do not know why
			tell checkbox "Require password to open document"
				click
			end tell
			(* add the password and confirm *)
			keystroke VarPassword
			keystroke (ASCII character 9)
			keystroke VarPassword
			
			tell its checkbox "Require password to copy text, images and other content"
				click
			end tell
			(* add the password and confirm *)
			keystroke FixedPassword
			keystroke (ASCII character 9)
			keystroke FixedPassword
			
			click button "OK"
		end tell
		
		repeat until exists sheet 1 of sheet 1 of front window
			delay 0.2
		end repeat
		
		-- Press command+shift+g to show the "Go" drop down sheet
		keystroke "g" using {command down, shift down}
		repeat until exists sheet of sheet 1 of sheet 1 of front window
			delay 0.2
		end repeat
		
		delay 0.5
		keystroke SaveFolder
		delay 0.5
		
		click button "Go" of sheet of sheet 1 of sheet 1 of front window
		
		-- Now that we are in our desired folder, set the file name and save
		set value of text field 1 of sheet 1 of sheet 1 of front window to FileName
		
		click button "Save" of sheet 1 of sheet 1 of front window
		
	end tell
end tell

([applescript] and [/applescript] code-posting tags added by NG.)