New version with undo and redo commands