Finish the write function
todo