implemented cached matrix inverse