refactoring render_context