Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision ebcadedc2eb5f524f09fc7618fe9f4fea00cdbb8)
+++ src/Makefile.am	(revision e9f8f930b09fee74ef361de63569c0744dc9509a)
@@ -1,4 +1,4 @@
 SOURCE = atom.cpp bond.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp helpers.cpp leastsquaremin.cpp linkedcell.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp
-HEADER = atom.hpp bond.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp helpers.hpp leastsquaremin.hpp linkedcell.hpp memoryallocator.hpp memoryusageobserver.cpp memoryusageobserver.hpp molecule.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp
+HEADER = atom.hpp bond.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp helpers.hpp leastsquaremin.hpp linkedcell.hpp memoryallocator.hpp memoryusageobserver.cpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp
 
 noinst_PROGRAMS =  ActOnAllTest VectorUnitTest MemoryAllocatorUnitTest MemoryUsageObserverUnitTest TesselationUnitTest
Index: src/atom.cpp
===================================================================
--- src/atom.cpp	(revision ebcadedc2eb5f524f09fc7618fe9f4fea00cdbb8)
+++ src/atom.cpp	(revision e9f8f930b09fee74ef361de63569c0744dc9509a)
@@ -102,4 +102,14 @@
 };
 
+/** Checks whether atom is within the given box.
+ * \param offset offset to box origin
+ * \param *parallelepiped box matrix
+ * \return true - is inside, false - is not
+ */
+bool atom::IsInParallelepiped(Vector offset, double *parallelepiped)
+{
+  return (node->IsInParallelepiped(offset, parallelepiped));
+};
+
 /** Output of a single atom.
  * \param ElementNo cardinal number of the element
@@ -112,4 +122,21 @@
   if (out != NULL) {
     *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t"  << fixed << setprecision(9) << showpoint;
+    *out << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2];
+    *out << "\t" << FixedIon;
+    if (v.Norm() > MYEPSILON)
+      *out << "\t" << scientific << setprecision(6) << v.x[0] << "\t" << v.x[1] << "\t" << v.x[2] << "\t";
+    if (comment != NULL)
+      *out << " # " << comment << endl;
+    else
+      *out << " # molecule nr " << nr << endl;
+    return true;
+  } else
+    return false;
+};
+bool atom::Output(int *ElementNo, int *AtomNo, ofstream *out, const char *comment)
+{
+  AtomNo[type->Z]++;  // increment number
+  if (out != NULL) {
+    *out << "Ion_Type" << ElementNo[type->Z] << "_" << AtomNo[type->Z] << "\t"  << fixed << setprecision(9) << showpoint;
     *out << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2];
     *out << "\t" << FixedIon;
Index: src/atom.hpp
===================================================================
--- src/atom.hpp	(revision ebcadedc2eb5f524f09fc7618fe9f4fea00cdbb8)
+++ src/atom.hpp	(revision e9f8f930b09fee74ef361de63569c0744dc9509a)
@@ -52,4 +52,5 @@
 
   bool Output(int ElementNo, int AtomNo, ofstream *out, const char *comment = NULL) const;
+  bool Output(int *ElementNo, int *AtomNo, ofstream *out, const char *comment = NULL);
   bool OutputXYZLine(ofstream *out) const;
   void EqualsFather ( atom *ptr, atom **res );
@@ -57,4 +58,6 @@
   atom *GetTrueFather();
   bool Compare(const atom &ptr);
+
+  bool IsInParallelepiped(Vector offset, double *parallelepiped);
 
   ostream & operator << (ostream &ost);
Index: src/helpers.cpp
===================================================================
--- src/helpers.cpp	(revision ebcadedc2eb5f524f09fc7618fe9f4fea00cdbb8)
+++ src/helpers.cpp	(revision e9f8f930b09fee74ef361de63569c0744dc9509a)
@@ -144,3 +144,2 @@
 };
 
-
Index: src/helpers.hpp
===================================================================
--- src/helpers.hpp	(revision ebcadedc2eb5f524f09fc7618fe9f4fea00cdbb8)
+++ src/helpers.hpp	(revision e9f8f930b09fee74ef361de63569c0744dc9509a)
@@ -273,4 +273,14 @@
 };
 
+template <typename T> void Increment(T *value, T inc)
+{
+  *value += inc;
+};
+
+template <typename T> void AbsoluteValue(T *value, T abs)
+{
+  *value = abs;
+};
+
 
 
Index: src/molecule.cpp
===================================================================
--- src/molecule.cpp	(revision ebcadedc2eb5f524f09fc7618fe9f4fea00cdbb8)
+++ src/molecule.cpp	(revision e9f8f930b09fee74ef361de63569c0744dc9509a)
@@ -6,4 +6,5 @@
 
 #include "config.hpp"
+#include "helpers.hpp"
 #include "memoryallocator.hpp"
 #include "molecule.hpp"
@@ -482,14 +483,8 @@
 {
   molecule *copy = new molecule(elemente);
-  atom *CurrentAtom = NULL;
   atom *LeftAtom = NULL, *RightAtom = NULL;
-  atom *Walker = NULL;
 
   // copy all atoms
-  Walker = start;
-  while(Walker->next != end) {
-    Walker = Walker->next;
-    CurrentAtom = copy->AddCopyAtom(Walker);
-  }
+  ActOnCopyWithEachAtom ( &molecule::AddCopyAtom, copy );
 
   // copy all bonds
@@ -532,13 +527,6 @@
 molecule* molecule::CopyMoleculeFromSubRegion(Vector offset, double *parallelepiped) {
   molecule *copy = new molecule(elemente);
-  atom *Walker = start;
-
-  while(Walker->next != end) {
-    Walker = Walker->next;
-    if (Walker->x.IsInParallelepiped(offset, parallelepiped)) {
-      cout << "Adding atom " << *Walker << endl;
-      copy->AddCopyAtom(Walker);
-    }
-  }
+
+  ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped );
 
   //TODO: copy->BuildInducedSubgraph((ofstream *)&cout, this);
@@ -721,5 +709,4 @@
 bool molecule::Output(ofstream *out)
 {
-  atom *walker = NULL;
   int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
   CountElements();
@@ -733,9 +720,5 @@
   } else {
     *out << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
-    walker = start;
-    while (walker->next != end) { // go through every atom of this element
-      walker = walker->next;
-      ElementNo[walker->type->Z] = 1;
-    }
+    SetIndexedArrayForEachAtomTo ( ElementNo, &element::Z, &AbsoluteValue, 1);
     int current=1;
     for (int i=0;i<MAX_ELEMENTS;++i) {
@@ -743,10 +726,5 @@
         ElementNo[i] = current++;
     }
-    walker = start;
-    while (walker->next != end) { // go through every atom of this element
-      walker = walker->next;
-      AtomNo[walker->type->Z]++;
-      walker->Output(ElementNo[walker->type->Z], AtomNo[walker->type->Z], out); // removed due to trajectories
-    }
+    ActOnAllAtoms( &atom::Output, ElementNo, AtomNo, out, (const char *) NULL ); // (bool (atom::*)(int *, int *, ofstream *, const char *))
     return true;
   }
@@ -775,15 +753,11 @@
         ElementNo[i] = 0;
       }
-    walker = start;
-    while (walker->next != end) { // go through every atom of this element
-      walker = walker->next;
-      ElementNo[walker->type->Z] = 1;
-    }
-    int current=1;
-    for (int i=0;i<MAX_ELEMENTS;++i) {
-      if (ElementNo[i] == 1)
-        ElementNo[i] = current++;
-    }
-    walker = start;
+      SetIndexedArrayForEachAtomTo ( ElementNo, &element::Z, &AbsoluteValue, 1);
+      int current=1;
+      for (int i=0;i<MAX_ELEMENTS;++i) {
+        if (ElementNo[i] == 1)
+          ElementNo[i] = current++;
+      }
+      walker = start;
       while (walker->next != end) { // go through every atom of this element
         walker = walker->next;
@@ -880,9 +854,5 @@
   if (out != NULL) {
     *out << AtomNo << "\n\tCreated by molecuilder on " << ctime(&now);
-    walker = start;
-    while (walker->next != end) { // go through every atom of this element
-      walker = walker->next;
-      walker->OutputXYZLine(out);
-    }
+    ActOnAllAtoms( &atom::OutputXYZLine, out );
     return true;
   } else
Index: src/molecule.hpp
===================================================================
--- src/molecule.hpp	(revision ebcadedc2eb5f524f09fc7618fe9f4fea00cdbb8)
+++ src/molecule.hpp	(revision e9f8f930b09fee74ef361de63569c0744dc9509a)
@@ -134,14 +134,54 @@
   // templates for allowing global manipulation of all vectors
   template <typename res> void ActOnAllVectors( res (Vector::*f)() );
+  template <typename res> void ActOnAllVectors( res (Vector::*f)() const);
+  template <typename res> void ActOnAllVectors( res (Vector::*f)() ) const;
   template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t );
+  template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T) const, T t );
+  template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t ) const;
   template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u );
+  template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u );
+  template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const;
   template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v);
+  template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v);
+  template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const;
+
+  // templates for allowing global manipulation of molecule with each atom as single argument
+  template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) );
+  template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) const);
+  template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) ) const;
+
+  // templates for allowing global copying of molecule with each atom as single argument
+  template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy);
+  template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const , molecule *copy);
+  template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const;
 
   // templates for allowing global manipulation of all atoms
-  template <typename res> void ActOnAllAtoms( res (molecule::*f)(atom *) );
   template <typename res> void ActOnAllAtoms( res (atom::*f)() );
+  template <typename res> void ActOnAllAtoms( res (atom::*f)() const );
+  template <typename res> void ActOnAllAtoms( res (atom::*f)() ) const;
   template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T), T t );
+  template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T) const, T t );
+  template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T) const, T t ) const;
   template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U), T t, U u );
+  template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u );
+  template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U), T t, U u ) const;
   template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v);
+  template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V) const, T t, U u, V v);
+  template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v) const;
+  template <typename res, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (atom::*f)(T, U, V, W), T t, U u, V v, W w);
+  template <typename res, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (atom::*f)(T, U, V, W) const, T t, U u, V v, W w);
+  template <typename res, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (atom::*f)(T, U, V, W), T t, U u, V v, W w) const;
+
+  // templates for allowing conditional global copying of molecule with each atom as single argument
+  template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () );
+  template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t );
+  template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u );
+  template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v );
+
+  // templates for allowing global manipulation of an array with one entry per atom
+  template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int atom::* index, void (*Setor)(T *, T));
+  template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int atom::* index, void (*Setor)(T *, T), T);
+  template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T));
+  template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T), T);
 
   /// remove atoms from molecule.
@@ -262,76 +302,5 @@
 };
 
-
-template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) {
-  atom *Walker = start;
-  while (Walker->next != end) {
-    Walker = Walker->next;
-    ((Walker->node)->*f)();
-  }
-};
-template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t )
-{
-  atom *Walker = start;
-  while (Walker->next != end) {
-    Walker = Walker->next;
-    ((Walker->node)->*f)(t);
-  }
-};
-template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u )
-{
-  atom *Walker = start;
-  while (Walker->next != end) {
-    Walker = Walker->next;
-    ((Walker->node)->*f)(t, u);
-  }
-};
-template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v)
-{
-  atom *Walker = start;
-  while (Walker->next != end) {
-    Walker = Walker->next;
-    ((Walker->node)->*f)(t, u, v);
-  }
-};
-
-template <typename res> void molecule::ActOnAllAtoms( res (molecule::*f)(atom *)) {
-  atom *Walker = start;
-  while (Walker->next != end) {
-    Walker = Walker->next;
-    (*f)(Walker);
-  }
-};
-
-template <typename res> void molecule::ActOnAllAtoms( res (atom::*f)()) {
-  atom *Walker = start;
-  while (Walker->next != end) {
-    Walker = Walker->next;
-    (Walker->*f)();
-  }
-};
-template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T), T t )
-{
-  atom *Walker = start;
-  while (Walker->next != end) {
-    Walker = Walker->next;
-    (Walker->*f)(t);
-  }
-};
-template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U), T t, U u )
-{
-  atom *Walker = start;
-  while (Walker->next != end) {
-    Walker = Walker->next;
-    (Walker->*f)(t, u);
-  }
-};
-template <typename res, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v)
-{
-  atom *Walker = start;
-  while (Walker->next != end) {
-    Walker = Walker->next;
-    (Walker->*f)(t, u, v);
-  }
-};
+#include "molecule_template.hpp"
 
 /** A list of \a molecule classes.
Index: src/molecule_template.hpp
===================================================================
--- src/molecule_template.hpp	(revision e9f8f930b09fee74ef361de63569c0744dc9509a)
+++ src/molecule_template.hpp	(revision e9f8f930b09fee74ef361de63569c0744dc9509a)
@@ -0,0 +1,378 @@
+/*
+ * molecule_template.hpp
+ *
+ *  Created on: Oct 6, 2009
+ *      Author: heber
+ */
+
+#ifndef MOLECULE_TEMPLATE_HPP_
+#define MOLECULE_TEMPLATE_HPP_
+
+// ================== Acting on all Vectors ========================== //
+
+// zero arguments
+template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    ((Walker->node)->*f)();
+  }
+};
+template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    ((Walker->node)->*f)();
+  }
+};
+template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const
+    {
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    ((Walker->node)->*f)();
+  }
+};
+// one argument
+template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    ((Walker->node)->*f)(t);
+  }
+};
+template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    ((Walker->node)->*f)(t);
+  }
+};
+template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    ((Walker->node)->*f)(t);
+  }
+};
+// two arguments
+template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    ((Walker->node)->*f)(t, u);
+  }
+};
+template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    ((Walker->node)->*f)(t, u);
+  }
+};
+template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    ((Walker->node)->*f)(t, u);
+  }
+};
+// three arguments
+template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v)
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    ((Walker->node)->*f)(t, u, v);
+  }
+};
+template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v)
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    ((Walker->node)->*f)(t, u, v);
+  }
+};
+template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    ((Walker->node)->*f)(t, u, v);
+  }
+};
+
+// ================== Acting with each Atoms on same molecule ========================== //
+
+// zero arguments
+template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *))
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (*f)(Walker);
+  }
+};
+template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const)
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (*f)(Walker);
+  }
+};
+template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (*f)(Walker);
+  }
+};
+
+// ================== Acting with each Atoms on copy molecule ========================== //
+
+// zero arguments
+template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy)
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (copy->*f)(Walker);
+  }
+};
+template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const , molecule *copy)
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (copy->*f)(Walker);
+  }
+};
+template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (copy->*f)(Walker);
+  }
+};
+
+// ================== Acting with each Atoms on copy molecule if true ========================== //
+
+// zero arguments
+template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    if ((Walker->*condition)())
+      (copy->*f)(Walker);
+  }
+};
+// one argument
+template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    if ((Walker->*condition)(t))
+      (copy->*f)(Walker);
+  }
+};
+// two arguments
+template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    if ((Walker->*condition)(t,u))
+      (copy->*f)(Walker);
+  }
+};
+// three arguments
+template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    if ((Walker->*condition)(t,u,v))
+      (copy->*f)(Walker);
+  }
+};
+
+// ================== Acting on all Atoms ========================== //
+
+// zero arguments
+template <typename res> void molecule::ActOnAllAtoms( res (atom::*f)())
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)();
+  }
+};
+template <typename res> void molecule::ActOnAllAtoms( res (atom::*f)() const)
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)();
+  }
+};
+template <typename res> void molecule::ActOnAllAtoms( res (atom::*f)()) const
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)();
+  }
+};
+// one argument
+template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T), T t )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)(t);
+  }
+};
+template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T) const, T t )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)(t);
+  }
+};
+template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T) const, T t ) const
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)(t);
+  }
+};
+// two argument
+template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U), T t, U u )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)(t, u);
+  }
+};
+template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)(t, u);
+  }
+};
+template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U), T t, U u ) const
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)(t, u);
+  }
+};
+// three argument
+template <typename res, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v)
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)(t, u, v);
+  }
+};
+template <typename res, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V) const, T t, U u, V v)
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)(t, u, v);
+  }
+};
+template <typename res, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v) const
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)(t, u, v);
+  }
+};
+// four arguments
+template <typename res, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V, W), T t, U u, V v, W w)
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)(t, u, v, w);
+  }
+};
+template <typename res, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V, W) const, T t, U u, V v, W w)
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)(t, u, v, w);
+  }
+};
+template <typename res, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V, W), T t, U u, V v, W w) const
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (Walker->*f)(t, u, v, w);
+  }
+};
+
+// ===================== Accesssing arrays indexed by some integer for each atom ======================
+
+// for atom ints
+template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int atom::*index, void (*Setor)(T *, T) )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (*Setor) (&array[(Walker->*index)], 1);
+  }
+};
+template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int atom::*index, void (*Setor)(T *, T), T value )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (*Setor) (&array[(Walker->*index)], value);
+  }
+};
+// for element ints inside atom class
+template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T) )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (*Setor) (&array[(Walker->type->*index)], 1);
+  }
+};
+template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T), T value )
+{
+  atom *Walker = start;
+  while (Walker->next != end) {
+    Walker = Walker->next;
+    (*Setor) (&array[(Walker->type->*index)], value);
+  }
+};
+
+#endif /* MOLECULE_TEMPLATE_HPP_ */
