Separate out cacheable function.