cache refactoring