added ability to save to a file