Added generation of matrix