refactoring page rendering