Implement save data function.