refactoring and allowing caching to not fall over if it hits an error