created function for cached matrix inverse