fixed valid_written issue