modified to update existing with cache