delete header & footer

Hi All

I have a program to delete header & footer from a quark document. But it is not working properly for every document.

Does any one think it should be changed, please suggest me some perfect changes.

tell application "QuarkXPress"
	activate
	tell front document
		set vertical measure to inches
		set horizontal measure to inches
		set tot to count of every generic box
		repeat with x from tot to 1 by -1
			set a1 to box type of generic box x as text
			if a1 = "LNBx" then
				delete generic box x
			end if
			
		end repeat
		
		
		set page rule origin to {"0", "0"}
		set aa to bounds of current box
		set tot to count of every generic box
		repeat with x from tot to 1 by -1
			set bb to bounds of generic box x
			if aa = bb then
				delete generic box x
			end if
			
		end repeat
		display dialog "Box of similar size  and position deleted successfully"
	end tell
end tell

Regards,
rajeev