fixed a bug in caching