diff --git a/processing/analyse.R b/processing/analyse.R
index b58519d2e35c8dc339bd67e843139e231602b70d..dad623eefb6a06572921e44797560f641093761b 100644
--- a/processing/analyse.R
+++ b/processing/analyse.R
@@ -150,14 +150,14 @@ get_QAtrend = function (df_data, df_meta, period, p_thresold) {
 ### 1.2. QMNA
 # Realise the trend analysis of the monthly minimum flow in the
 # year (QMNA) hydrological variable
-get_QMNAtrend = function (df_data, df_meta, period, p_thresold) {
+get_QMNAtrend = function (df_data, df_meta, period, p_thresold, sampleSpan) {
 
     # Removes incomplete data from time series
     df_data = remove_incomplete_data(df_data, df_meta,
                                      yearLac_pct=1, yearStart='01-01')
     # Samples the data
     df_data = sampling_data(df_data, df_meta,
-                            sampleSpan=c('05-01', '11-30'))
+                            sampleSpan=sampleSpan)
     
     # Make sure to convert the period to a list
     period = as.list(period)
@@ -219,7 +219,7 @@ get_QMNAtrend = function (df_data, df_meta, period, p_thresold) {
 ### 1.3. VCN10
 # Realises the trend analysis of the minimum 10 day average flow
 # over the year (VCN10) hydrological variable
-get_VCN10trend = function (df_data, df_meta, period, p_thresold) {
+get_VCN10trend = function (df_data, df_meta, period, p_thresold, sampleSpan) {
 
     # Removes incomplete data from time series
     df_data = remove_incomplete_data(df_data, df_meta,
@@ -227,7 +227,7 @@ get_VCN10trend = function (df_data, df_meta, period, p_thresold) {
 
     # Samples the data
     df_data = sampling_data(df_data, df_meta,
-                            sampleSpan=c('05-01', '11-30'))
+                            sampleSpan=sampleSpan)
     
     # Get all different stations code
     Code = levels(factor(df_meta$code))
@@ -294,11 +294,61 @@ get_VCN10trend = function (df_data, df_meta, period, p_thresold) {
 ### 1.4. tINI date
 
 which_underfirst = function (L, UpLim) {
-    id = which(L <= UpLim)[1]
+    ID = which(L <= UpLim)
+    
+    dID = diff(ID)
+    dID = c(10, dID)
+    
+    IDjump = which(dID != 1)
+    Njump = length(IDjump)
+
+    # print('ID')
+    # print(ID)
+    # print('dID')
+    # print(dID)
+    # print('IDjump')
+    # print(IDjump)
+    # print('')
+
+    Periods = vector(mode='list', length=Njump)
+    Nperiod = c()
+    
+    for (i in 1:Njump) {
+        
+        idStart = IDjump[i]
+        
+        if (i < Njump) {
+            idEnd = IDjump[i+1] - 1
+        } else {
+            idEnd = length(ID)
+        }
+
+        # print(paste('Start', idStart))
+        # print(paste('End', idEnd))
+
+        period = ID[idStart:idEnd]
+
+        # print(period)
+        # print('')
+        
+        Periods[[i]] = period
+        Nperiod = c(Nperiod, length(period))
+    }
+
+    period_max = Periods[[which.max(Nperiod)]]
+    
+    id = period_max[1]
+
+    # print(Nperiod)
+    # print(id)
+
+    # print('')
+    # print('NEXT')
+    # print('')
     return (id)
 }
 
-get_tINItrend = function (df_data, df_meta, period, p_thresold) {
+get_tINItrend = function (df_data, df_meta, period, p_thresold, sampleSpan) {
 
     # Get all different stations code
     Code = levels(factor(df_meta$code))
@@ -364,8 +414,7 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) {
             # Samples the data
             df_data_code = sampling_data(df_data_code,
                                          df_meta=NULL,
-                                         sampleSpan=c('05-01',
-                                                      '11-30'),
+                                         sampleSpan=sampleSpan,
                                          Code=code)
             
             # Removes incomplete data from the averaged time series
@@ -378,8 +427,7 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) {
             # Samples the data
             df_data_roll_code = sampling_data(df_data_roll_code,
                                               df_meta=NULL,
-                                              sampleSpan=c('05-01',
-                                                           '11-30'),
+                                              sampleSpan=sampleSpan,
                                               Code=code)
 
             # print('bb')
@@ -484,7 +532,7 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) {
 ### 1.5. tMID date
 # Realises the trend analysis of the date of the minimum 10 day
 # average flow over the year (VCN10) hydrological variable
-get_tMIDtrend = function (df_data, df_meta, period, p_thresold) {
+get_tMIDtrend = function (df_data, df_meta, period, p_thresold, sampleSpan) {
     
     # Get all different stations code
     Code = levels(factor(df_meta$code))
@@ -511,7 +559,7 @@ get_tMIDtrend = function (df_data, df_meta, period, p_thresold) {
                                           yearStart='01-01')
     # Samples the data
     df_data_roll = sampling_data(df_data_roll, df_meta,
-                                 sampleSpan=c('05-01', '11-30'))
+                                 sampleSpan=sampleSpan)
 
     # Make sure to convert the period to a list
     period = as.list(period)
diff --git a/script.R b/script.R
index ce5eb3868deb231729f75a44187ea614e248fd3e..2d206b77579770fd89bc1a2f96567ffb685ae585 100644
--- a/script.R
+++ b/script.R
@@ -62,12 +62,12 @@ filename =
         # "P1712910_HYDRO_QJM.txt",
         # "P0885010_HYDRO_QJM.txt",
         # "O5055010_HYDRO_QJM.txt",
-        "O0384010_HYDRO_QJM.txt"
+        # "O0384010_HYDRO_QJM.txt"
         # "S4214010_HYDRO_QJM.txt",
         # "Q7002910_HYDRO_QJM.txt"
         # "O3035210_HYDRO_QJM.txt",
-        # "O3121010_HYDRO_QJM.txt",
-        # "O0362510_HYDRO_QJM.txt"
+        # "O0554010_HYDRO_QJM.txt",
+        "O1584610_HYDRO_QJM.txt"
     )
 
 
@@ -106,6 +106,9 @@ mean_period = list(period1, period2)
 # p value thresold
 p_thresold = 0.1
 
+# Sampling span of the data
+sampleSpan = c('05-01', '11-30')
+
 
 ## MAP
 # Path to the shapefile for france contour from 'computer_data_path' 
@@ -232,23 +235,27 @@ res_QAtrend = get_QAtrend(df_data, df_meta,
 # QMNA tend
 res_QMNAtrend = get_QMNAtrend(df_data, df_meta,
                               period=trend_period,
-                              p_thresold=p_thresold)
+                              p_thresold=p_thresold,
+                              sampleSpan=sampleSpan)
 
 # VCN10 trend
-res_VCN10trend = get_VCN10trend(df_data, df_meta, 
+res_VCN10trend = get_VCN10trend(df_data, df_meta,
                                 period=trend_period,
-                                p_thresold=p_thresold)
+                                p_thresold=p_thresold,
+                                sampleSpan=sampleSpan)
 
 # Start date for low water trend
 res_tINItrend = get_tINItrend(df_data, df_meta, 
                               period=trend_period,
-                              p_thresold=p_thresold)
+                              p_thresold=p_thresold,
+                              sampleSpan=sampleSpan)
 # res_tINItrend = read_listofdf(resdir, 'res_tINItrend')
 
 # Center date for low water trend
 res_tMIDtrend = get_tMIDtrend(df_data, df_meta, 
                               period=trend_period,
-                              p_thresold=p_thresold)
+                              p_thresold=p_thresold,
+                              sampleSpan=sampleSpan)
 
 ### 3.3. Break analysis
 # df_break = get_break(res_QAtrend$data, df_meta)