implement caching for the data has already been computed