made small changes to file saving method