refactor in MatrixRenderer and MatrixGenerator