correct matrix computation