adding code for writing to disk so far have not compiled or run yet