refactoring cache