refactoring the rendering engine