fixed writer bug