refactory the cache