proper renderPage() function