added caching code