new function to update a value in the matrix