add a new local variable to track if digests are being stored, to ensure the cleanup works correctly