modified with function to cache inverse of invertible matrix