refactor; separate generation from render
great refactoring