updated to save flat pages