fixed gmatrix bug