refactoring graphicengine