add callback fun for write