Fixed error and added caching