fix some bugs in sam output