refactoring cache helper