added memory caching