Converted addPage to use the new query function