Correct matrix is calculated