diff --git a/include/reactphysics3d/systems/CollisionDetectionSystem.h b/include/reactphysics3d/systems/CollisionDetectionSystem.h
index 93fd9dc3..89ed2f32 100644
--- a/include/reactphysics3d/systems/CollisionDetectionSystem.h
+++ b/include/reactphysics3d/systems/CollisionDetectionSystem.h
@@ -159,6 +159,9 @@ class CollisionDetectionSystem {
         /// Pointer to the contact points of the current frame (either mContactPoints1 or mContactPoints2)
         List<ContactPoint>* mCurrentContactPoints;
 
+        /// Array with the indices of all the contact pairs that have at least one CollisionBody
+        List<uint32> mCollisionBodyContactPairsIndices;
+
 #ifdef IS_RP3D_PROFILING_ENABLED
 
     /// Pointer to the profiler
diff --git a/src/systems/CollisionDetectionSystem.cpp b/src/systems/CollisionDetectionSystem.cpp
index 0e4146f2..756acda1 100644
--- a/src/systems/CollisionDetectionSystem.cpp
+++ b/src/systems/CollisionDetectionSystem.cpp
@@ -67,7 +67,7 @@ CollisionDetectionSystem::CollisionDetectionSystem(PhysicsWorld* world, Collider
                      mContactManifolds1(mMemoryManager.getPoolAllocator()), mContactManifolds2(mMemoryManager.getPoolAllocator()),
                      mPreviousContactManifolds(&mContactManifolds1), mCurrentContactManifolds(&mContactManifolds2),
                      mContactPoints1(mMemoryManager.getPoolAllocator()), mContactPoints2(mMemoryManager.getPoolAllocator()),
-                     mPreviousContactPoints(&mContactPoints1), mCurrentContactPoints(&mContactPoints2) {
+                     mPreviousContactPoints(&mContactPoints1), mCurrentContactPoints(&mContactPoints2), mCollisionBodyContactPairsIndices(mMemoryManager.getSingleFrameAllocator()) {
 
 #ifdef IS_RP3D_PROFILING_ENABLED
 
@@ -623,13 +623,23 @@ void CollisionDetectionSystem::addContactPairsToBodies() {
 
         ContactPair& contactPair = (*mCurrentContactPairs)[p];
 
+        const bool isBody1Rigid = mRigidBodyComponents.hasComponent(contactPair.body1Entity);
+        const bool isBody2Rigid = mRigidBodyComponents.hasComponent(contactPair.body2Entity);
+
         // Add the associated contact pair to both bodies of the pair (used to create islands later)
-        if (mRigidBodyComponents.hasComponent(contactPair.body1Entity)) {
+        if (isBody1Rigid) {
            mRigidBodyComponents.addContacPair(contactPair.body1Entity, p);
         }
-        if (mRigidBodyComponents.hasComponent(contactPair.body2Entity)) {
+        if (isBody2Rigid) {
            mRigidBodyComponents.addContacPair(contactPair.body2Entity, p);
         }
+
+        // If at least of body is a CollisionBody
+        if (!isBody1Rigid || !isBody2Rigid) {
+
+            // Add the pair index to the array of pairs with CollisionBody
+            mCollisionBodyContactPairsIndices.add(p);
+        }
     }
 }
 
@@ -814,15 +824,7 @@ void CollisionDetectionSystem::createContacts() {
     // We go through all the contact pairs and add the pairs with a least a CollisionBody at the end of the
     // mProcessContactPairsOrderIslands array because those pairs have not been added during the islands
     // creation (only the pairs with two RigidBodies are added during island creation)
-    Set<uint32> processedContactPairsIndices(mMemoryManager.getSingleFrameAllocator(), mCurrentContactPairs->size());
-    for (uint32 i=0; i < mWorld->mProcessContactPairsOrderIslands.size(); i++) {
-        processedContactPairsIndices.add(mWorld->mProcessContactPairsOrderIslands[i]);
-    }
-    for (uint32 i=0; i < mCurrentContactPairs->size(); i++) {
-        if (!processedContactPairsIndices.contains(i)) {
-            mWorld->mProcessContactPairsOrderIslands.add(i);
-        }
-    }
+    mWorld->mProcessContactPairsOrderIslands.addRange(mCollisionBodyContactPairsIndices);
 
     assert(mWorld->mProcessContactPairsOrderIslands.size() == (*mCurrentContactPairs).size());
 
@@ -883,6 +885,8 @@ void CollisionDetectionSystem::createContacts() {
     // Compute the map from contact pairs ids to contact pair for the next frame
     computeMapPreviousContactPairs();
 
+    mCollisionBodyContactPairsIndices.clear(true);
+
     mNarrowPhaseInput.clear();
 }