fix samwriter