   return (color);
 }
 
+
+void moveGridTo(int startPos, int nextRow, int nextFrame) {
+  int pos, i, j;
+  bool isGridMoved = false;
+
+  debugPrintGrid();
+
+  // While we haven't move each row
+  // while ((startPos >= 0) && (startPos <= 15)) {
+  for(i = 0; i < 4; i++) {
+      
+    pos = startPos;
+    // For the 3 next frame (the first one is obviously already placed to the limit)
+    for (j = 0; j < 3; j++) {
+      // Go to the next frame
+      pos += nextFrame;
+      if (moveFrame(pos, -nextFrame, startPos))
+        isGridMoved = true;
+    }
+
+    // Go to the next row
+    startPos += nextRow;
+  }
+
+  if (isGridMoved)
+    insertNumber();
+
+  Serial.println("Move done dude !");
+  debugPrintGrid();
+}
+
+bool moveFrame(int pos, int nextFrame, int limit) {
+  bool hasMoved = false;
+
+  while (pos != limit) {
+    
+    Serial.print("Try to move frame ");
+    Serial.print(pos);
+    Serial.print(" to ");
+    Serial.println(pos + nextFrame);
+
+    if ((_grid[pos] != 0) && (_grid[pos + nextFrame] == 0)) {
+      _grid[pos + nextFrame] = _grid[pos];
+      _grid[pos] = 0;
+      hasMoved = true;
+    }
+
+    pos += nextFrame;
+  }
+  Serial.println("");
+
+  return (hasMoved);
+}
+
+
+/**
+ * Insert a new frame in the grid
+ */
 void insertNumber() {
   long index = random(16);
-  
   long number = random(100);
   
+  // Search a free grid frame. TODO: find a better way to do this
   while (_grid[index] != 0) {
     index = random(16);
   }
   
+  // Determine the weight of the new frame. 66% chances to have a 2
   if (number < 66)
     _grid[index] = 2;
   else

      else if (vertical == 4)
        currentDirection = Down;
      else if (horizontal == 0)
        currentDirection = Left;
      else
        currentDirection = Right;
    }
  }
  // Else check if the joystick is back to its default position

    isDefaultPosition = true;

  return (currentDirection);
}

void debugPrintGrid() {
  int i = 0;

  while (i < 16) {
    if (i % 4 == 0)
      Serial.print("[");
    
    Serial.print(_grid[i++]);

    if (i % 4 == 0)
      Serial.println("]");
    else
      Serial.print(", ");
  }
}