fixed writer bugs