I did add debugging code and this is what its showing.
page number:4
page number:NaN
So I'm not sure why it would be populating it twice. As for a different approach I felt this would be the quickest and none problematic, but I guess I was wrong.
I'm at a lost on why it only does this on the last page.
The code is the same on all the pages, I would be more than happy to post a copy of the page if it would help.