refactoring renderer and event handling