         }
         let scale = min(xScale, yScale)
         
-        pointIndex = 0
+        var pointIndex = 0
         return inputDigit.map { subPath in
             return subPath.filter({ point in
                 let drop = pointIndex % dropIndexes == 0
                 pointIndex++
                 return !drop
             }).map({ point in
-                let x = (point.x - xMean) * scale
-                let y = (point.y - yMean) * scale
+                let x = (point.x - xTranslate) * scale
+                let y = (point.y - yTranslate) * scale
                 return CGPointMake(x, y)
             })
         }

                        println("Normalizing a troubled digit")
                    }
                    let normalizedDigit = normalizeDigit(prototype)
                    addToLibrary(&self.normalizedPrototypeLibrary, label: label, digit: normalizedDigit)
                }
            }

    }
    
    func greedyDynamicTimeWarp(sample: [CGPoint], prototype: [CGPoint]) -> CGFloat {
        let minNeighborSize = 3
        let maxNeighborSize = 5
        if sample.count < minNeighborSize * 4 || prototype.count < minNeighborSize * 4 {
            return CGFloat.max
        }
