Refactor digest