added update method to update every time data is changed