diff --git a/include/evalhyd/detail/masks.hpp b/include/evalhyd/detail/masks.hpp
index daee3e255d3b1cbd373223b6d53d0e4a507cd8cb..7a818ba5d76f605b60ecedd42d73ed91969891e6 100644
--- a/include/evalhyd/detail/masks.hpp
+++ b/include/evalhyd/detail/masks.hpp
@@ -165,10 +165,11 @@ namespace evalhyd
         }
 
         /// Function to generate temporal mask based on masking conditions
+        template<class X1, class X2>
         inline xt::xtensor<bool, 1> generate_mask_from_conditions(
                 const std::array<char, 32>& msk_char_arr,
-                const xt::xtensor<double, 1>& q_obs,
-                const xt::xtensor<double, 2>& q_prd = {}
+                const X1& q_obs,
+                const X2& q_prd
         )
         {
             // parse string to identify masking conditions
@@ -200,7 +201,7 @@ namespace evalhyd
                     auto get_q = [&]() {
                         if (var == "q_obs")
                         {
-                            return q_obs;
+                            return xt::xtensor<double, 1>(q_obs);
                         }
                         else if (var == "q_prd_median")
                         {