diff --git a/algo/evbuild/EventBuilder.h b/algo/evbuild/EventBuilder.h
index 948956f3aaa3105c754eb7353dcd527b24575138..94f3d94d92280b4b54a5327d6353a10ed4edd734 100644
--- a/algo/evbuild/EventBuilder.h
+++ b/algo/evbuild/EventBuilder.h
@@ -101,9 +101,11 @@ namespace cbm
       template<typename Data>
       static typename std::vector<Data> CopyRange(const std::vector<Data>& source, double tMin, double tMax)
       {
-        auto comp  = [](const Data& obj, double value) { return obj.GetTime() < value; };
-        auto lower = std::lower_bound(source.begin(), source.end(), tMin, comp);
-        auto upper = std::lower_bound(lower, source.end(), tMax, comp);
+        //auto comp  = [](const Data& obj, double value) { return obj.GetTime() < value; };
+        auto comp1 = [](const Data& obj, double value) { return obj.GetTime() < value; };
+        auto comp2 = [](double value, const Data& obj) { return value < obj.GetTime(); };
+        auto lower = std::lower_bound(source.begin(), source.end(), tMin, comp1);
+        auto upper = std::upper_bound(lower, source.end(), tMax, comp2);
         return std::vector<Data>(lower, upper);
       }