logic fix for cache flush