fixed the matrix creation