Simplify the toDigitsRev function