added code to write the useful parts to disk