small fix on cache logic