diff --git a/R/PE_Oudin.R b/R/PE_Oudin.R
index 7b748c54e1ef703cdabda0a3db8c1f27f6adb760..e8f56053ac2dede903335b00724fe8ff333f2b86 100644
--- a/R/PE_Oudin.R
+++ b/R/PE_Oudin.R
@@ -41,11 +41,10 @@ PE_Oudin <- function(JD, Temp,
   TimeStepIn  <- match.arg(TimeStepIn , choices = TimeStep)
   TimeStepOut <- match.arg(TimeStepOut, choices = TimeStep)
   rleJD <- rle(JD)
+  msgDaliy <- "each day should have only one identical value of julian days. The time series is not sorted, or contains duplicate or missing dates"
+  msgHourly <- "each day must have 24 identical values of julian days (one for each hour). The time series is not sorted, or contains duplicate or missing dates"
   if (TimeStepIn == "daily" & any(rleJD$lengths != 1)) {
-    warning("each day should have only one identical value of julian days. The time series is not sorted, or contains duplicate or missing dates")
-  }
-  if (TimeStepIn == "hourly" & any(rleJD$lengths != 24)) {
-    warning("each day must have 24 identical values of julian days (one for each hour). The time series is not sorted, or contains duplicate or missing dates")
+    warning(msgDaliy)
   }
 
 
@@ -54,7 +53,14 @@ PE_Oudin <- function(JD, Temp,
   if (TimeStepIn == "hourly") {
     JD <- rleJD$values
     idJD <- rep(seq_along(JD), each = rleJD$lengths[1L])
-    Temp <- as.vector(tapply(X = Temp, INDEX = idJD, FUN = mean))
+    if (length(Temp) != length(idJD)) {
+      stop(msgHourly)
+    } else {
+      Temp <- as.vector(tapply(X = Temp, INDEX = idJD, FUN = mean))
+    }
+  }
+  if (TimeStepIn == "hourly" & any(rleJD$lengths != 24)) {
+    warning(msgHourly)
   }