fixed bug in caching