change write function;now with  cb(ok)