added caching functionality