refactoring: move rendering code to view