added logic to save the data to disk