finished save_data function