Minor update in write_cache method