Adding pages to the end of a Pages document with AppleScript

I’m working on a script that takes content from slides in Keynote and moves it over to Pages, creating a new page for each slide. For the most part the script is working, but it’s adding the pages in the wrong order. Is it possible to create a new page in a specific place in the order of pages in a document (specifically, at the end)?

Here’s my code. This function will be run multiple times, and each time it’s supposed to take a string and put it on a new page at the end of the document.

Let me know if you see something wrong:

on makeNextPagesPage(content)
tell application "Pages"
	-- use the existing document, or make a new blank one
	if exists window 1 then
		set pagesDoc to the front document
		set pagesDoc to make new document with properties {document template:template "Blank"}
	end if
	tell pagesDoc
		set thisPage to ""
		if body text of pagesDoc is "" then
			set thisPage to the first page of pagesDoc
			set thisPage to make new page at the end of pagesDoc
		end if
		set body text of the last page of section 1 to content
	        end tell
        end tell
end makeNextPagesPage


Try the suggestion here: