refactor cache