             betterTau = Float(tau)
             
         }
-        
-        return betterTau
+
+        return fabs(betterTau)
     }
     
     class func sumSquare(yinBuffer:[Float], start:Int, end:Int) -> Float {

        let inputCount = bufferSizePOT / 2
        let fftSetup = vDSP_create_fftsetup(log2n, Int32(kFFTRadix2))

        var audioRealp = [Float](repeating: 0, count: inputCount)
        var audioImagp = [Float](repeating: 0, count: inputCount)
        var audioTransformedComplex = DSPSplitComplex(realp: &audioRealp, imagp: &audioImagp)

            res + element * element
        }

        var powerTermFirstElement:Float = 0.0
        for j in 0 ..< yinBufferSize {
            powerTermFirstElement += buffer[j] * buffer[j]
        }

        powerTerms[0] = powerTermFirstElement

