diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6b72c04002bdac1ca15fa9d7920dd2ba2102eb02..573c32251fd780fb0dccad675121173f923a4569 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -68,6 +68,8 @@ SET(CPP_FILES
   grouping/groupingexperiment.cpp
   grouping/groupinggroup.cpp
   grouping/groupingpeptidemass.cpp
+  grouping/ptm/ptmgroupingexperiment.cpp
+  grouping/ptm/ptmisland.cpp
   gui/peptide_detail_view/spectrum_widget/spectrumpainter.cpp
   input/xpipsaxhandler.cpp
   input/xtandemsaxhandler.cpp
diff --git a/src/core/peptidematch.cpp b/src/core/peptidematch.cpp
index 32426026227fd9e5940ded88e74ca2ca1abb54c0..d2e718d733c1ab58c66cb402186c0bc90c088e0b 100644
--- a/src/core/peptidematch.cpp
+++ b/src/core/peptidematch.cpp
@@ -97,7 +97,7 @@ unsigned int PeptideMatch::getStop() const {
     return _start+_peptide_sp.get()->size();
 }
 
-void PeptideMatch::containsPosition(unsigned int position) {
+bool PeptideMatch::containsPosition(unsigned int position) const {
     if (position < _start) {
         return false;
     }
diff --git a/src/core/peptidematch.h b/src/core/peptidematch.h
index 06b095855f26eeac8daac96ff326d5bd72f67d1d..93b6d92ececb2b0e8908c602f02a462836297ec1 100644
--- a/src/core/peptidematch.h
+++ b/src/core/peptidematch.h
@@ -110,10 +110,10 @@ public :
 
     ValidationState getValidationState() const;
     
-    /** @brief tells if this peptide contains a position
+    /** @brief tells if this peptide contains a protein position
      * the position is the amino acid position on the protein sequence (starts from 0)
      * */
-    void containsPosition(unsigned int position);
+    bool containsPosition(unsigned int position) const;
 
 private :
     static std::hash<std::string> _hash_fn;
diff --git a/src/grouping/ptm/ptmisland.cpp b/src/grouping/ptm/ptmisland.cpp
index ad392bb88a1e5a43a02e8aff89df0152dd692f47..a4e892dfcbfc128679505abd4695a62622f0250e 100644
--- a/src/grouping/ptm/ptmisland.cpp
+++ b/src/grouping/ptm/ptmisland.cpp
@@ -30,12 +30,15 @@
 #include "ptmisland.h"
 #include <pappsomspp/pappsoexception.h>
 
-PtmIsland::PtmIsland(const ProteinMatch* p_protein_match, unsigned int position)
+PtmIsland::PtmIsland(const ProteinMatch* p_protein_match, unsigned int position):_protein_match_p(p_protein_match)
 {
     _position_list.push_back(position);
-    _protein_match_p = p_protein_match;
 }
 
+
+PtmIsland::PtmIsland(const PtmIsland & other):_protein_match_p(other._protein_match_p) {
+    _position_list = other._position_list;
+}
 PtmIsland::~PtmIsland()
 {
 
@@ -67,27 +70,27 @@ bool PtmIsland::merge(PtmIslandSp ptm_island_sp) {
     }
     else {
         //so we merge
-        _peptide_match_list.insert(0,ptm_island_sp.get()->_peptide_match_list.begin(),ptm_island_sp.get()->_peptide_match_list.end());
+        _peptide_match_list.insert(_peptide_match_list.begin(),ptm_island_sp.get()->_peptide_match_list.begin(),ptm_island_sp.get()->_peptide_match_list.end());
         std::sort(_peptide_match_list.begin(), _peptide_match_list.end());
         auto last = std::unique(_peptide_match_list.begin(), _peptide_match_list.end());
         _peptide_match_list.erase(last, _peptide_match_list.end());
-	
-	_position_list.insert(0,ptm_island_sp.get()->_position_list.begin(),ptm_island_sp.get()->_position_list.end());
+
+        _position_list.insert(_position_list.begin(),ptm_island_sp.get()->_position_list.begin(),ptm_island_sp.get()->_position_list.end());
         std::sort(_position_list.begin(), _position_list.end());
         _position_list.erase(std::unique(_position_list.begin(), _position_list.end()), _position_list.end());
 
 
-        PeptideMatch  * result = std::max_element(_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch * a, const PeptideMatch * b)
+        std::vector<const PeptideMatch *>::const_iterator it_result = std::max_element(_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch * a, const PeptideMatch * b)
         {
-            return  a->getStop() < b->getStop();
+            return  (a->getStop() < b->getStop());
         });
-        _protein_stop = result->getStop();
+        _protein_stop = (*it_result)->getStop();
 
-        result = std::min_element(_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch * a, const PeptideMatch * b)
+        it_result = std::min_element(_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch * a, const PeptideMatch * b)
         {
             return  a->getStart() < b->getStart();
         });
-        _protein_start = result->getStart();
+        _protein_start = (*it_result)->getStart();
         return true;
     }
 }
diff --git a/src/grouping/ptm/ptmisland.h b/src/grouping/ptm/ptmisland.h
index bd89cdbc8835bd462e5be513cca5f023c4250a6a..3f5014675f5297a4ce7a7baa4983b8286a7cadcd 100644
--- a/src/grouping/ptm/ptmisland.h
+++ b/src/grouping/ptm/ptmisland.h
@@ -34,7 +34,6 @@
 #include "../../core/peptidematch.h"
 #include <memory>
 
-PtmIslandSp
 
 class PtmIsland;
 
@@ -46,6 +45,7 @@ class PtmIsland
 {
 public:
     PtmIsland(const ProteinMatch* p_protein_match, unsigned int position);
+    PtmIsland(const PtmIsland & other);
     ~PtmIsland();
     void addPeptideMatch(const PeptideMatch* p_peptide_match);
     
@@ -55,8 +55,8 @@ public:
     
     bool containsPeptideMatch(const PeptideMatch* element) const;
 private:
-    ProteinMatch * _protein_match_p;
-    std::vector<PeptideMatch *> _peptide_match_list;
+    const ProteinMatch * _protein_match_p;
+    std::vector<const PeptideMatch *> _peptide_match_list;
     //std::vector<std::size_t> _sample_scan_set;
     unsigned int _group_number; //group together different ptmislands linked by a common protein
     unsigned int _subgroup_number; //group together proteins that share the same ptmisland