Taking out common code from set and update.