fix some bugs in attachment