refactored the cache library