Added cache for shape method