Modify backup logic to avoid crash