fix bug in caching