Index: src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp
===================================================================
--- src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp	(revision 9e23a3785b6bdd916d370ba9157e9b76a1905c53)
+++ src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp	(revision 20943bae7a201e8b438123cacbc942e875e959a9)
@@ -22,9 +22,12 @@
 #include "atom.hpp"
 #include "Helpers/defs.hpp"
+#include "CodePatterns/Assert.hpp"
 #include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "Dynamics/LinearInterpolationBetweenSteps.hpp"
 #include "molecule.hpp"
-#include "CodePatterns/Verbose.hpp"
 #include "World.hpp"
 
+#include <vector>
 #include <iostream>
 #include <fstream>
@@ -40,19 +43,18 @@
 /** =========== define the function ====================== */
 Action::state_ptr MoleculeLinearInterpolationofTrajectoriesAction::performCall() {
-  molecule *mol = NULL;
-
   // obtain information
   getParametersfromValueStorage();
 
-  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
-    mol = iter->second;
-    DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << params.start << " and " << params.end << "." << endl);
-    if (params.IdMapping)
-      DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
-    if (!mol->LinearInterpolationBetweenConfiguration(params.start, params.end, params.filename.branch_path().string(), *(World::getInstance().getConfig()), params.IdMapping))
-      DoLog(2) && (Log() << Verbose(2) << "Could not store " << params.filename << " files." << endl);
-    else
-      DoLog(2) && (Log() << Verbose(2) << "Steps created and " << params.filename << " files stored." << endl);
-  }
+  DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << params.start << " and " << params.end << "." << endl);
+  if (params.IdMapping)
+    DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
+  ASSERT(params.end > params.start, "MoleculeLinearInterpolationofTrajectoriesAction() - start step greater than end step.");
+  AtomSetMixin<std::vector<atom*> > set(World::getInstance().getSelectedAtoms());
+  LinearInterpolationBetweenSteps<std::vector<atom*> > LinearInterpolate(set,(unsigned int)(params.end-params.start));
+  if (!LinearInterpolate(params.start, params.end, params.filename.branch_path().string(), params.IdMapping))
+    DoLog(2) && (Log() << Verbose(2) << "Could not store " << params.filename << " files." << endl);
+  else
+    DoLog(2) && (Log() << Verbose(2) << "Steps created and " << params.filename << " files stored." << endl);
+
   return Action::success;
 }
Index: src/Dynamics/LinearInterpolationBetweenSteps.hpp
===================================================================
--- src/Dynamics/LinearInterpolationBetweenSteps.hpp	(revision 20943bae7a201e8b438123cacbc942e875e959a9)
+++ src/Dynamics/LinearInterpolationBetweenSteps.hpp	(revision 20943bae7a201e8b438123cacbc942e875e959a9)
@@ -0,0 +1,123 @@
+/*
+ * LinearInterpolationBetweenSteps.hpp
+ *
+ *  Created on: Feb 23, 2011
+ *      Author: heber
+ */
+
+#ifndef LINEARINTERPOLATIONBETWEENSTEPS_HPP_
+#define LINEARINTERPOLATIONBETWEENSTEPS_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <vector>
+
+#include "atom.hpp"
+#include "AtomSet.hpp"
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "Dynamics/MinimiseConstrainedPotential.hpp"
+#include "molecule.hpp"
+#include "parser.hpp"
+#include "World.hpp"
+
+template <class Set>
+class LinearInterpolationBetweenSteps
+{
+public:
+  LinearInterpolationBetweenSteps(AtomSetMixin<Set> &_atoms, unsigned int _MaxOuterStep) :
+    MDSteps(0),
+    MaxOuterStep(_MaxOuterStep),
+    IsAngstroem(true),
+    atoms(_atoms)
+  {}
+  ~LinearInterpolationBetweenSteps()
+  {}
+
+  /** Performs a linear interpolation between two desired atomic configurations with a given number of steps.
+   * Note, step number is config::MaxOuterStep
+   * \param *out output stream for debugging
+   * \param startstep stating initial configuration in molecule::Trajectories
+   * \param endstep stating final configuration in molecule::Trajectories
+   * \param &prefix path and prefix
+   * \param MapByIdentity if true we just use the identity to map atoms in start config to end config, if not we find mapping by \sa MinimiseConstrainedPotential()
+   * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories
+   */
+  bool operator()(int startstep, int endstep, std::string prefix, bool MapByIdentity)
+  {
+    // TODO: rewrite permutationMaps using enumeration objects
+    molecule *mol = NULL;
+    bool status = true;
+    int MaxSteps = MaxOuterStep;
+    MoleculeListClass *MoleculePerStep = new MoleculeListClass(World::getPointer());
+    // Get the Permutation Map by MinimiseConstrainedPotential
+    atom **PermutationMap = NULL;
+    atom *Sprinter = NULL;
+    if (!MapByIdentity) {
+      molecule::atomSet atoms_list;
+      copy(atoms.begin(), atoms.end(), atoms_list.begin());
+      MinimiseConstrainedPotential Minimiser(atoms_list);
+      Minimiser(PermutationMap, startstep, endstep, IsAngstroem);
+    } else {
+      // TODO: construction of enumeration goes here
+      PermutationMap = new atom *[atoms.size()];
+      for(typename AtomSetMixin<Set>::const_iterator iter = atoms.begin(); iter != atoms.end();++iter){
+        PermutationMap[(*iter)->getNr()] = (*iter);
+      }
+    }
+
+    // check whether we have sufficient space in Trajectories for each atom
+    for(typename AtomSetMixin<Set>::iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
+      (*iter)->ResizeTrajectory(MaxSteps);
+    }
+    // push endstep to last one
+    for(typename AtomSetMixin<Set>::iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
+      (*iter)->CopyStepOnStep(MaxSteps,endstep);
+    }
+    endstep = MaxSteps;
+
+    // go through all steps and add the molecular configuration to the list and to the Trajectories of \a this molecule
+    DoLog(1) && (Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl);
+    for (int step = 0; step <= MaxSteps; step++) {
+      mol = World::getInstance().createMolecule();
+      MoleculePerStep->insert(mol);
+      for (typename AtomSetMixin<Set>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
+        // add to molecule list
+        Sprinter = mol->AddCopyAtom((*iter));
+        // add to Trajectories
+        Vector temp = (*iter)->getPositionAtStep(startstep) + (PermutationMap[(*iter)->getNr()]->getPositionAtStep(endstep) - (*iter)->getPositionAtStep(startstep))*((double)step/(double)MaxSteps);
+        Sprinter->setPosition(temp);
+        (*iter)->setAtomicVelocityAtStep(step, zeroVec);
+        (*iter)->setAtomicForceAtStep(step, zeroVec);
+        //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
+      }
+    }
+    MDSteps = MaxSteps+1;   // otherwise new Trajectories' points aren't stored on save&exit
+
+    // store the list to single step files
+    int *SortIndex = new int[atoms.size()];
+    for (int i=atoms.size(); i--; )
+      SortIndex[i] = i;
+
+    status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
+    delete[](SortIndex);
+
+    // free and return
+    delete[](PermutationMap);
+    delete(MoleculePerStep);
+    return status;
+  };
+
+private:
+  unsigned int MDSteps;
+  unsigned int MaxOuterStep;
+  bool IsAngstroem;
+  AtomSetMixin<Set> atoms;
+
+};
+
+#endif /* LINEARINTERPOLATIONBETWEENSTEPS_HPP_ */
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 9e23a3785b6bdd916d370ba9157e9b76a1905c53)
+++ src/Makefile.am	(revision 20943bae7a201e8b438123cacbc942e875e959a9)
@@ -123,4 +123,5 @@
 
 DYNAMICSHEADER = \
+	Dynamics/LinearInterpolationBetweenSteps.hpp \
 	Dynamics/MinimiseConstrainedPotential.hpp
 
Index: src/molecule.hpp
===================================================================
--- src/molecule.hpp	(revision 9e23a3785b6bdd916d370ba9157e9b76a1905c53)
+++ src/molecule.hpp	(revision 20943bae7a201e8b438123cacbc942e875e959a9)
@@ -181,6 +181,4 @@
   void RotateToPrincipalAxisSystem(Vector &Axis);
 
-  bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string prefix, config &configuration, bool MapByIdentity);
-
   bool CheckBounds(const Vector *x) const;
   void GetAlignvector(struct lsq_params * par) const;
Index: src/molecule_dynamics.cpp
===================================================================
--- src/molecule_dynamics.cpp	(revision 9e23a3785b6bdd916d370ba9157e9b76a1905c53)
+++ src/molecule_dynamics.cpp	(revision 20943bae7a201e8b438123cacbc942e875e959a9)
@@ -38,74 +38,4 @@
 /************************************* Functions for class molecule *********************************/
 
-
-/** Performs a linear interpolation between two desired atomic configurations with a given number of steps.
- * Note, step number is config::MaxOuterStep
- * \param *out output stream for debugging
- * \param startstep stating initial configuration in molecule::Trajectories
- * \param endstep stating final configuration in molecule::Trajectories
- * \param &prefix path and prefix
- * \param &config configuration structure
- * \param MapByIdentity if true we just use the identity to map atoms in start config to end config, if not we find mapping by \sa MinimiseConstrainedPotential()
- * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories
- */
-bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string prefix, config &configuration, bool MapByIdentity)
-{
-  // TODO: rewrite permutationMaps using enumeration objects
-  molecule *mol = NULL;
-  bool status = true;
-  int MaxSteps = configuration.MaxOuterStep;
-  MoleculeListClass *MoleculePerStep = new MoleculeListClass(World::getPointer());
-  // Get the Permutation Map by MinimiseConstrainedPotential
-  atom **PermutationMap = NULL;
-  atom *Sprinter = NULL;
-  if (!MapByIdentity) {
-    MinimiseConstrainedPotential Minimiser(atoms);
-    Minimiser(PermutationMap, startstep, endstep, configuration.GetIsAngstroem());
-  } else {
-    // TODO: construction of enumeration goes here
-    PermutationMap = new atom *[getAtomCount()];
-    for(internal_iterator iter = atoms.begin(); iter != atoms.end();++iter){
-      PermutationMap[(*iter)->getNr()] = (*iter);
-    }
-  }
-
-  // check whether we have sufficient space in Trajectories for each atom
-  LOG(1, "STATUS: Extending each trajectory size to " << MaxSteps+1 << ".");
-  for_each(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::ResizeTrajectory),MaxSteps+1));
-  // push endstep to last one
-  for_each(atoms.begin(),atoms.end(),boost::bind(&atom::CopyStepOnStep,_1,MaxSteps,endstep));
-  endstep = MaxSteps;
-
-  // go through all steps and add the molecular configuration to the list and to the Trajectories of \a this molecule
-  DoLog(1) && (Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl);
-  for (int step = 0; step <= MaxSteps; step++) {
-    mol = World::getInstance().createMolecule();
-    MoleculePerStep->insert(mol);
-    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-      // add to molecule list
-      Sprinter = mol->AddCopyAtom((*iter));
-      // add to Trajectories
-      Vector temp = (*iter)->getPositionAtStep(startstep) + (PermutationMap[(*iter)->getNr()]->getPositionAtStep(endstep) - (*iter)->getPositionAtStep(startstep))*((double)step/(double)MaxSteps);
-      Sprinter->setPosition(temp);
-      (*iter)->setAtomicVelocityAtStep(step, zeroVec);
-      (*iter)->setAtomicForceAtStep(step, zeroVec);
-      //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
-    }
-  }
-  MDSteps = MaxSteps+1;   // otherwise new Trajectories' points aren't stored on save&exit
-
-  // store the list to single step files
-  int *SortIndex = new int[getAtomCount()];
-  for (int i=getAtomCount(); i--; )
-    SortIndex[i] = i;
-
-  status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
-  delete[](SortIndex);
-
-  // free and return
-  delete[](PermutationMap);
-  delete(MoleculePerStep);
-  return status;
-};
 
 /** Parses nuclear forces from file and performs Verlet integration.
