         self.viewMain.layer.addSublayer(layer)
         return layer
     }()
-    lazy var maskView:UIImageView = {
+    lazy var imageView:UIImageView = {
         let view = UIImageView(frame: self.viewMain.bounds)
         view.image = self.image
         view.contentMode = .ScaleAspectFit

        }
        layers.removeAll()
        index = 0
        maskView.image = image
        setTransformAnimated(CGAffineTransformIdentity)
        updateUI()
    }
    
    @IBAction func undo() {
        index -= 1
        maskView.image = image
        renderLayers(0..<index)
        updateUI()
    }

    private func renderLayers(range:Range<Int>) {
        UIGraphicsBeginImageContext(image.size)
        let context = UIGraphicsGetCurrentContext()!
        imageView.image?.drawInRect(CGRect(origin: .zero, size: image.size))
        CGContextConcatCTM(context, imageTransform)
        CGContextSetBlendMode(context, CGBlendMode.DestinationOut)
        for i in range {
            layers[i].renderInContext(context)
        }
        imageView.image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
    }
}
