created and updated the functions for matrix inversion