refactoring the cache to be its own object