minor improvement for matrix