change method for saving data to the database