private Image buffer(final Image img) {
		Graphics g = img.getGraphics();
		Graphics2D g2d = (Graphics2D) g;
		clearScreen(g);
		for (int rows = 0; rows < gameBoard.length; rows++) {
			for (int columns = 0; columns < gameBoard[rows].length; columns++) {
				int x = columns * sideSize;
				int y = rows * sideSize;
				if (animating && new Point(columns, rows).equals(toMove)) {
					animateBlock(g, rows, columns);

				} else {
					if (gameBoard[rows][columns] != 0) {
						g.drawImage(imageMap.get(gameBoard[rows][columns]), x,
								y, null);
					} else {
						if (checkIfSolved() && !scrambling) {
							g.drawImage(imageMap.get(gameBoard[rows][columns]),
									x, y, null);
						}
					}
				}
				if (!checkIfSolved() || scrambling) {
					g2d.setColor(Color.BLACK);
					g2d.drawRect(x, y, sideSize, sideSize);
				}
			}
		}
		return img;
	}