Converted pageExists to use the new query function