modify matrix