Rewrite digest, avoid using list (to avoid a shadow warning), and avoid using head (partial function)