fix bug when caching metadata