improving caching unpersisting logic