 }
 __device__ func max_func = max_d;
 
+double max_identity_element = - DBL_MAX;
 
 Point3D reduce_max(PointCloud<Point3D> &cloud) {
-    return reduce(cloud, max_func);
+    return reduce(cloud, max_func, max_identity_element);
 }
+
 
 __device__ double min_d(double n, double m) {
     return (m < n) ? m : n;
 }
 __device__ func min_func = min_d;
 
+double min_identity_element = DBL_MAX;
 
 Point3D reduce_min(PointCloud<Point3D> &cloud) {
-    return reduce(cloud, min_func);
+    return reduce(cloud, min_func, min_identity_element);
 }

    cudaFree(d_points);
    cudaFree(d_result);
    cudaFree(d_reduce);

    cudaFree(d_f);
    free(h_f);


}

Point3D reduce(PointCloud<Point3D> &cloud, func& f, double identity_element) {

    Point3D *d_points;
    Point3D *d_result;

    auto num_points = cloud.points.size();

    auto size = next_power_of_two(num_points);

    func* h_f;
    func* d_f;
