       } else if i == 2 {
         color = blockColors.count > 2 ? blockColors[2] : UIColor(white: 0.6, alpha: 1.0)
       }
-      
+
       for j in 0..<5 {
         let block = SKSpriteNode(color: color, size: CGSize(width: 5, height: 19))
         block.position = CGPoint(x: 20+CGFloat(i)*6, y: CGFloat(j)*20 + 10)
         block.name = blockName
         block.physicsBody = SKPhysicsBody(rectangleOfSize: block.size)
-        
+
         block.physicsBody?.categoryBitMask = blockCategory
         block.physicsBody?.allowsRotation = false
         block.physicsBody?.restitution = 1.0
         block.physicsBody?.friction = 0.0
-//        block.physicsBody?.mass = 1000.0
         block.physicsBody?.dynamic = false
-        
+
         addChild(block)
       }
     }
   }
-  
+
+  func removeBlocks() {
+    var node = childNodeWithName(blockName)
+    while (node != nil) {
+      node?.removeFromParent()
+      node = childNodeWithName(blockName)
+    }
+  }
+
   func createBall() {
     let ball = SKSpriteNode(color: ballColor, size: CGSize(width: 8, height: 8))
-    
-    
+
+
     ball.position = CGPoint(x: frame.size.width - 30.0 - ball.size.width, y: CGRectGetHeight(frame)*CGFloat(arc4random())/CGFloat(UINT32_MAX))
     ball.name = ballName
-    
+
     ball.physicsBody = SKPhysicsBody(circleOfRadius: ceil(ball.size.width/2.0))
     ball.physicsBody?.usesPreciseCollisionDetection = true
     ball.physicsBody?.categoryBitMask = ballCategory
-    ball.physicsBody?.contactTestBitMask = blockCategory | paddleCategory
+    ball.physicsBody?.contactTestBitMask = blockCategory | paddleCategory | backCategory
     ball.physicsBody?.allowsRotation = false
-    
+
     ball.physicsBody?.linearDamping = 0.0
     ball.physicsBody?.restitution = 1.0
     ball.physicsBody?.friction = 0.0
-    
+
     addChild(ball)
   }
-  
+
   func removeBall() {
-    let ball = childNodeWithName(ballName)
-    ball?.removeFromParent()
-  }
-  
+    if let ball = childNodeWithName(ballName) {
+      ball.removeFromParent()
+    }
+  }
+
   func createLoadingLabelNode() {
     let loadingLabelNode = SKLabelNode(text: "Loading...")
     loadingLabelNode.fontColor = UIColor.lightGrayColor()
     loadingLabelNode.fontSize = 20
     loadingLabelNode.position = CGPoint(x: CGRectGetMidX(frame), y: CGRectGetMidY(frame))
     loadingLabelNode.name = backgroundLabelName
-    
+
     addChild(loadingLabelNode)
   }
-  
+
   func reset() {
+    removeBlocks()
     createBlocks()
     removeBall()
     createBall()
   }
-  
+
   func start() {
     isStarted = true
-    
+
     let ball = childNodeWithName(ballName)
     ball?.physicsBody?.applyImpulse(CGVector(dx: -0.5, dy: 0.2))
   }
-  
+
   func updateLabel(text: String) {
-    let label : SKLabelNode! = childNodeWithName(backgroundLabelName) as? SKLabelNode;
-    label?.text = text
-  }
-  
+    if let label: SKLabelNode = childNodeWithName(backgroundLabelName) as? SKLabelNode {
+      label.text = text
+    }
+  }
+
   func moveHandle(value: CGFloat) {
-//    println("\(value)")
-    
     let paddle = childNodeWithName(paddleName)
-    
+
     paddle?.position.y = value
   }
-  
+
   func didEndContact(contact: SKPhysicsContact) {
     var ballBody: SKPhysicsBody?
     var otherBody: SKPhysicsBody?
-    
-//    println("--------------------------------------------")
-//    println("A \(contact.bodyA) \(contact.bodyA.categoryBitMask) \(ballCategory)")
-//    println("B \(contact.bodyB) \(contact.bodyB.categoryBitMask) \(ballCategory)")
+
     if contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask {
-//      println("first")
       ballBody = contact.bodyA
       otherBody = contact.bodyB
     } else {
-//      println("second")
       ballBody = contact.bodyB
       otherBody = contact.bodyA
     }
-    
-    if ballBody!.categoryBitMask & ballCategory != 0 {
+
+    if ((otherBody?.categoryBitMask ?? 0) == backCategory) {
+      reset()
+      start()
+    } else if ballBody!.categoryBitMask & ballCategory != 0 {
       let minimalXVelocity = CGFloat(20.0)
       let minimalYVelocity = CGFloat(20.0)
       var velocity = ballBody!.velocity as CGVector
-//      println("ball category: \(ballBody?.categoryBitMask)")
-//      println("before \(velocity.dx) \(velocity.dy)")
       if velocity.dx > -minimalXVelocity && velocity.dx <= 0 {
         velocity.dx = -minimalXVelocity-1
       } else if velocity.dx > 0 && velocity.dx < minimalXVelocity {

    startNode.fontSize = 20
    startNode.position = CGPoint(x: CGRectGetMidX(frame), y: CGRectGetMidY(frame))
    startNode.name = "start"
    
    return startNode
  }
  

      } else if velocity.dy > 0 && velocity.dy < minimalYVelocity {
        velocity.dy = minimalYVelocity+1
      }
      ballBody?.velocity = velocity
    }

    if otherBody != nil && (otherBody!.categoryBitMask & blockCategory != 0) && otherBody!.categoryBitMask == blockCategory {
      otherBody!.node?.removeFromParent()
      if isGameWon() {
        reset()
        start()
      }
    }
  }
  
  func isGameWon() -> Bool {
