seperated the save functionality to a single file