added support for undo and stroke limit