fix a possible race condition on hashAlgorithm