         }
 
         drawCube(color: NSColor.greenColor(), skip: skip)
+        
+        cubeCount += 1
     }
     
     func drawCube(#color: NSColor, skip: Int)


class KrkklView : ScreenSaverView
{
    var numrows = 100
    var pos:     (x: Int, y: Int) = (0, 0)
    var size:    (x: Int, y: Int) = (0, 0)
    var center:  (x: Int, y: Int) = (0, 0)

    var lastPos:Int = 0
    var nextPos:Int = 0
    var reset: String = "random" // what happens when the screen border is touched: "wrap", "center" or "random"
    var keepdir: [Float] = [0,0,0,0,0,0,0]
    
    override init(frame: NSRect, isPreview: Bool) 
    {

    {
        let context = window!.graphicsContext
        NSGraphicsContext.setCurrentContext(context)
        
        if animState == "fade"
        {
            fadeOut()
        }
        else
        {
            if cubeCount >= maxCubes
            {
                animState = "fade"
                debugPrint(animState)
                fadeCount = 0
            }
            drawNextCube()
        }
        
        context?.flushGraphics()
    }
    
    func fadeOut()
    {
        if fadeCount >= 100
        {
            clear()
            setup()
            animState = "anim"
        }
        else
        {
            clear(color:NSColor(red: 0, green: 0, blue: 0, alpha: 0.02))
            fadeCount += 1
        }
    }
    
    func cubeSize() -> (w: Int, h: Int) 
