insert open/close items automatically (with some bugs)