Final version with matrix & inverse verification