setup caching refactored code