Updated code to cache inverse of matrix