cache update code optimized