fix onWrite