refactored to share code between render and renderPageView