working on writing data out