Added undo/redo functionality while drawing.