 			rigid_data.angmom[idx_body] = angmom2;
 			rigid_data.angvel[idx_body] = angvel;
 			}	
-		}
+		
 				
-	if (idx_body < rigid_data.n_bodies && idx_particle_index != INVALID_INDEX)
-		{
-		// v_particle = v_com + angvel x xr
-		float4 particle_vel;
-		particle_vel.x = vel2.x + angvel.y * ri.z - angvel.z * ri.y;
-		particle_vel.y = vel2.y + angvel.z * ri.x - angvel.x * ri.z;
-		particle_vel.z = vel2.z + angvel.x * ri.y - angvel.y * ri.x;
-		particle_vel.w = 0.0;
+		if (idx_body < rigid_data.n_bodies && idx_particle_index != INVALID_INDEX)
+			{
+			// v_particle = v_com + angvel x xr
+			float4 pvel;
+			pvel.x = vel2.x + angvel.y * ri.z - angvel.z * ri.y;
+			pvel.y = vel2.y + angvel.z * ri.x - angvel.x * ri.z;
+			pvel.z = vel2.z + angvel.x * ri.y - angvel.y * ri.x;
+			pvel.w = 0.0;
 			
-		// write out the results 
-		pdata.vel[idx_particle_index] = particle_vel;
-		}
-			
+			// write out the results 
+			pdata.vel[idx_particle_index] = pvel;
+			}
+		}	
 	}
 
 

	if (error != cudaSuccess)
		return error;

    
	
	// run the kernel for particles
	gpu_nve_rigid_particle_pre_step_kernel<<< particle_grid, particle_threads >>>(pdata, rigid_data, box, deltaT, limit, limit_val);
		
		
	if (!g_gpu_error_checking)
		{

	if (error != cudaSuccess)
		return error;
		
	// bind the textures for particles: pos, vel, accel and image of ALL particles
	error = cudaBindTexture(0, pdata_pos_tex, pdata.pos, sizeof(float4) * pdata.N);
	if (error != cudaSuccess)
