Added code for the ccalculation of the inverse