stop calculation if det(M) = 0