Created functions for matrix invertion