diff --git a/corsika/detail/modules/pythia8/Decay.inl b/corsika/detail/modules/pythia8/Decay.inl
index 54cbf5a7d1c3fcd63d0964e8a83d6498ce673d3b..2a71c1b971f424992b30db9dccb0d09b768ab660 100644
--- a/corsika/detail/modules/pythia8/Decay.inl
+++ b/corsika/detail/modules/pythia8/Decay.inl
@@ -33,8 +33,7 @@ namespace corsika::pythia8 {
     // run this only once during construction
 
     // link random number generator in pythia to CORSIKA8
-    Pythia8::RndmEngine* rndm = new corsika::pythia8::Random();
-    Pythia8::Pythia::setRndmEnginePtr(rndm);
+    Pythia8::Pythia::setRndmEnginePtr(std::make_shared<corsika::pythia8::Random>());
 
     Pythia8::Pythia::readString("Next:numberShowInfo = 0");
     Pythia8::Pythia::readString("Next:numberShowProcess = 0");
diff --git a/corsika/detail/modules/pythia8/Interaction.inl b/corsika/detail/modules/pythia8/Interaction.inl
index 6dc08b99e0520d433282bc1215476fc97b220ac1..60c51efc26008e6796593163d55f612686221341 100644
--- a/corsika/detail/modules/pythia8/Interaction.inl
+++ b/corsika/detail/modules/pythia8/Interaction.inl
@@ -33,7 +33,7 @@ namespace corsika::pythia8 {
       : print_listing_(print_listing)
       , pythiaMain_{CORSIKA_Pythia8_XML_DIR, false}
       , pythiaColl_{CORSIKA_Pythia8_XML_DIR, false} {
-    Pythia8::RndmEngine* rndm = new corsika::pythia8::Random();
+    auto rndm = std::make_shared<corsika::pythia8::Random>();
     pythiaColl_.setRndmEnginePtr(rndm);
     pythiaMain_.setRndmEnginePtr(rndm);