added write_to_disk method