caching and refactoring