refactoring (put rendering code to the separate module