dv is just a local variable to the calcDv function, the calcDv calculates the dv based on the sum, and it used to be just (sum % 11), the bug that I fixed happens when sum % 11 === 0, in that case the dv was not being set to 0, causing valid CPF numbers to fail validation.