updated code - inverse matrix