refactor page rendering