Index: src/Parser/FormatParser_common.cpp
===================================================================
--- src/Parser/FormatParser_common.cpp	(revision efc80ef549eeaa87e6de7ecddb9bbcf6b0387276)
+++ src/Parser/FormatParser_common.cpp	(revision ef8667b4d260efd11751453df376ebe1f809ee1e)
@@ -36,5 +36,7 @@
 
 #include <iostream>
-
+#include <limits>
+
+#include "CodePatterns/Assert.hpp"
 #include "CodePatterns/Observer/Notification.hpp"
 #include "World.hpp"
@@ -179,2 +181,26 @@
   return iter->second;
 }
+
+std::pair<size_t, size_t> FormatParser_common::getMinMaxTrajectories(
+    const std::vector<const atom *> &_atoms) const
+{
+  // get max and min trajectories
+  size_t min_trajectories = std::numeric_limits<size_t>::max();
+  size_t max_trajectories = std::numeric_limits<size_t>::min();
+  for (std::vector<const atom *>::const_iterator iter = _atoms.begin();
+      iter != _atoms.end();
+      ++iter) {
+    if (max_trajectories < (*iter)->getTrajectorySize())
+      max_trajectories = (*iter)->getTrajectorySize();
+    if (min_trajectories > (*iter)->getTrajectorySize())
+      min_trajectories = (*iter)->getTrajectorySize();
+  }
+  // no atoms? Then, they all have same amount
+  if (_atoms.size() == 0)
+    min_trajectories = max_trajectories = 1;
+  ASSERT(min_trajectories == max_trajectories,
+      "FormatParser_common::getMinMaxTrajectories() - not all atoms have same number of trajectories: "
+      +toString(min_trajectories)+" != "+toString(max_trajectories)+".");
+
+  return std::make_pair(min_trajectories, max_trajectories);
+}
Index: src/Parser/FormatParser_common.hpp
===================================================================
--- src/Parser/FormatParser_common.hpp	(revision efc80ef549eeaa87e6de7ecddb9bbcf6b0387276)
+++ src/Parser/FormatParser_common.hpp	(revision ef8667b4d260efd11751453df376ebe1f809ee1e)
@@ -56,4 +56,7 @@
   int getLocalId(const int global) const;
 
+  std::pair<size_t, size_t> getMinMaxTrajectories(
+      const std::vector<const atom *> &_atoms) const;
+
 private:
   //!> Output stream to write to when save() is called.
Index: src/Parser/PdbParser.cpp
===================================================================
--- src/Parser/PdbParser.cpp	(revision efc80ef549eeaa87e6de7ecddb9bbcf6b0387276)
+++ src/Parser/PdbParser.cpp	(revision ef8667b4d260efd11751453df376ebe1f809ee1e)
@@ -198,14 +198,7 @@
 
   // check for maximum number of time steps
-  size_t max_timesteps = 0;
-  for (vector<const atom *>::const_iterator atomIt = AtomList.begin();
-      atomIt != AtomList.end(); atomIt++) {
-    const atom * _atom = *atomIt;
-    LOG(4, "INFO: Atom " << _atom->getName() << " "
-        << *dynamic_cast<const AtomInfo *>(_atom) << ".");
-    if (_atom->getTrajectorySize() > max_timesteps)
-      max_timesteps = _atom->getTrajectorySize();
-  }
-  LOG(2,"INFO: Found a maximum of " << max_timesteps << " time steps to store.");
+  std::pair<size_t, size_t> minmax_trajectories =
+      getMinMaxTrajectories(AtomList);
+  LOG(2, "INFO: There are " << minmax_trajectories.second << " steps to save.");
 
   // re-distribute serials
@@ -222,5 +215,5 @@
 
   // store all time steps (always do first step)
-  for (size_t step = 0; (step == 0) || (step < max_timesteps); ++step) {
+  for (size_t step = 0; (step == 0) || (step < minmax_trajectories.second); ++step) {
     {
       // add initial remark
Index: src/Parser/XyzParser.cpp
===================================================================
--- src/Parser/XyzParser.cpp	(revision efc80ef549eeaa87e6de7ecddb9bbcf6b0387276)
+++ src/Parser/XyzParser.cpp	(revision ef8667b4d260efd11751453df376ebe1f809ee1e)
@@ -169,24 +169,10 @@
 
   // get max and min trajectories
-  size_t min_trajectories = std::numeric_limits<size_t>::max();
-  size_t max_trajectories = std::numeric_limits<size_t>::min();
-  for (std::vector<const atom *>::const_iterator iter = atoms.begin();
-      iter != atoms.end();
-      ++iter) {
-    if (max_trajectories < (*iter)->getTrajectorySize())
-      max_trajectories = (*iter)->getTrajectorySize();
-    if (min_trajectories > (*iter)->getTrajectorySize())
-      min_trajectories = (*iter)->getTrajectorySize();
-  }
-  // no atoms? Then, they all have same amount
-  if (atoms.size() == 0)
-    min_trajectories = max_trajectories = 1;
-  ASSERT(min_trajectories == max_trajectories,
-      "FormatParser< xyz >::save() - not all atoms have same number of trajectories: "
-      +toString(min_trajectories)+" != "+toString(max_trajectories)+".");
-  LOG(2, "INFO: There are " << max_trajectories << " steps to save.");
+  std::pair<size_t, size_t> minmax_trajectories =
+      getMinMaxTrajectories(atoms);
+  LOG(2, "INFO: There are " << minmax_trajectories.second << " steps to save.");
 
   // always store at least one step
-  for (size_t step = 0; (step < max_trajectories) || (step == 0); ++step) {
+  for (size_t step = 0; (step < minmax_trajectories.second) || (step == 0); ++step) {
     if (step != 0)
       *file << "\n";
