         float maxDistance = get<8>(rayTuple);
         eavlVector3 rayOrigin(get<3>(rayTuple),get<4>(rayTuple),get<5>(rayTuple));
         eavlVector3       ray(get<0>(rayTuple),get<1>(rayTuple),get<2>(rayTuple));
-        minHit = getIntersectionTri(ray, rayOrigin, false,bvh,tri_bvh_lf_raw, verts,maxDistance,distance);
-    
+        if(primitiveType == TRIANGLE)
+        {
+            minHit = getIntersectionTri(ray, rayOrigin, false,bvh,bvh_inner, verts,maxDistance,distance);
+        } 
+        else if(primitiveType == SPHERE)
+        {
+            minHit = getIntersectionSphere(ray, rayOrigin, false,bvh,bvh_inner, verts,maxDistance,distance);
+        }
+        
         if(minHit!=-1) return tuple<int,float,int>(minHit, distance, TRIANGLE);
         else           return tuple<int,float,int>(hitIdx, INFINITE, get<7>(rayTuple));
     }

    eavlExecutor::AddOperation(new_eavlMapOp(eavlOpArgs(rayDirX,rayDirY,rayDirZ,rayOriginX,rayOriginY,rayOriginZ,hitIdx,primitiveTypeHit,minDistances),
                                             eavlOpArgs(hitIdx, minDistances, primitiveTypeHit),
                                             RayIntersectFunctor(tri_verts_array,tri_bvh_in_array,tri_bvh_lf_array,TRIANGLE)),
                                                                                                    "intersect");
    eavlExecutor::Go();



    eavlConstArrayV2<float4> verts;
    eavlConstArrayV2<float4> bvh;
    eavlConstArrayV2<float>  bvh_inner;
    primitive_t              primitiveType;

    RayIntersectFunctor(eavlConstArrayV2<float4> *_verts, eavlConstArrayV2<float4> *theBvh,eavlConstArrayV2<float> *_bvh_inner, primitive_t _primitveType)
        :verts(*_verts),
         bvh(*theBvh),
         bvh_inner(*_bvh_inner),
         primitiveType(_primitveType)
    {}                                                 
    EAVL_HOSTDEVICE tuple<int,float,int> operator()( tuple<float,float,float,float,float,float,int, int, float> rayTuple){
       
