Corrected render and query logic for pages.