fix writing  error