extracted caching to functions