caching_function refactor round 1