added an update function to database