update image and fix undo bug