updated to include matrixInvert