Relating code: public void undo() { chessboard.initialize(x, y, chessboard.getPiece(x_target, y_target)); chessboard.initialize(x_target, y_target, piece); addRedoCommand(this); } This is the undo function in CmdMove class. It will result in incorrect undo results in some cases like a pawn changes to queen since it only undo the position information instead of the full information of pieces.