refactor for caching