diff --git a/src/input/mascot/mascotdatparser.cpp b/src/input/mascot/mascotdatparser.cpp
index 2751237a0a751c14299c1022a9896098525761fc..6837689ff331620b1394308397b6b0176ba8a3e4 100644
--- a/src/input/mascot/mascotdatparser.cpp
+++ b/src/input/mascot/mascotdatparser.cpp
@@ -447,11 +447,21 @@ MascotDatParser::parsePeptidesLine(const QString &peptide_line)
           QString index           = header_list[1];
           QString value           = header_list[2];
           QStringList index_list  = index.split("_");
+
+
+          QString query_index_str         = index_list[0];
+          unsigned int query_index_number = query_index_str.mid(1).toUInt();
+          if((value != "-1") &&
+             (query_index_number != _current_peptide.query_index))
+            {
+              saveAndClearPeptide();
+            }
+          _current_peptide.query_index = query_index_number;
+
           if(index_list.size() == 3)
             {
               if(index_list[2] == "db")
                 {
-                  saveAndClearPeptide();
                   // q1_p1_db=02
                   while(value.size() > 0)
                     {
@@ -476,9 +486,7 @@ MascotDatParser::parsePeptidesLine(const QString &peptide_line)
               else
                 {
 
-                  QString query_index          = index_list[0];
-                  _current_peptide.query_index = query_index.mid(1).toUInt();
-                  QString peptide_index        = index_list[1];
+                  QString peptide_index = index_list[1];
                   _current_peptide.peptide_index =
                     peptide_index.mid(1).toUInt();
                   // q1_p1=0,597.302322,0.997884,2,GAWHK,9,0000000,7.97,0000012000000000000,0,0;"sp|O95006|OR2F2_HUMAN":0:299:303:1
@@ -698,12 +706,22 @@ MascotDatParser::saveQuery()
   qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
   if(_current_query.query_index > 0)
     {
-      std::vector<PeptideLine> peptide_list =
-        _query_peptide_results[_current_query.query_index - 1];
-      savePeptideList(peptide_list, false);
-      peptide_list =
-        _decoy_query_peptide_results[_current_query.query_index - 1];
-      savePeptideList(peptide_list, true);
+      try
+        {
+          std::vector<PeptideLine> peptide_list =
+            _query_peptide_results[_current_query.query_index - 1];
+          savePeptideList(peptide_list, false);
+          peptide_list =
+            _decoy_query_peptide_results[_current_query.query_index - 1];
+          savePeptideList(peptide_list, true);
+        }
+      catch(pappso::PappsoException &error)
+        {
+          throw pappso::PappsoException(
+            QObject::tr("ERROR saving MASCOT query%1 :\n %2")
+              .arg(_current_query.query_index)
+              .arg(error.qwhat()));
+        }
     }
   qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
@@ -803,14 +821,6 @@ MascotDatParser::savePeptideList(std::vector<PeptideLine> &peptide_list,
       // peptide_str << " evalue="  << peptide_evidence.getEvalue() << "
       // ionscore=" << ion_score;
 
-      if(peptide_line.protein_string_list.size() !=
-         peptide_line.fasta_file_list.size())
-        {
-          throw pappso::PappsoException(
-            QObject::tr("ERROR (peptide_line.protein_string_list.size() != "
-                        "peptide_line.fasta_file_list.size()) %1")
-              .arg(peptide_line.protein_string_list.join(",\"")));
-        }
 
       unsigned int i = 0;
       foreach(const QString &str, peptide_line.protein_string_list)
@@ -834,7 +844,31 @@ MascotDatParser::savePeptideList(std::vector<PeptideLine> &peptide_list,
           // qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__;
           ProteinXtp protein;
           protein.setAccession(accession);
-          protein.setFastaFileP(peptide_line.fasta_file_list[i].get());
+          if(peptide_line.fasta_file_list.size() == 0)
+            {
+              if(_fasta_file_list.size() == 1)
+                {
+                  protein.setFastaFileP(_fasta_file_list[0].get());
+                }
+              else
+                {
+                  throw pappso::PappsoException(
+                    QObject::tr("ERROR no FASTA file"));
+                }
+            }
+          else
+            {
+              if(i < peptide_line.fasta_file_list.size())
+                {
+
+                  protein.setFastaFileP(peptide_line.fasta_file_list[i].get());
+                }
+              else
+                {
+                  throw pappso::PappsoException(
+                    QObject::tr("ERROR no corresponding FASTA file %1").arg(i));
+                }
+            }
           if(is_decoy)
             {
               protein.setIsDecoy(true);
@@ -904,7 +938,8 @@ MascotDatParser::setVariableModifications(PeptideXtpSp &peptide_sp,
   for(unsigned int i = 0; i < variable_modifications_string.size(); i++)
     {
       qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
-               << variable_modifications_string.mid(i, 1).toUInt();
+               << variable_modifications_string.mid(i, 1).toUInt() << " "
+               << variable_modifications_string;
       if(variable_modifications_string.mid(i, 1).toUInt() > 0)
         {
           MascotModification mascot_modification = _delta_modification_list
@@ -913,10 +948,14 @@ MascotDatParser::setVariableModifications(PeptideXtpSp &peptide_sp,
             {
               if(i > 0)
                 {
-                  i = i - 1;
+                  peptide_sp.get()->addAaModification(
+                    mascot_modification.modification, i - 1);
+                }
+              else
+                {
+                  peptide_sp.get()->addAaModification(
+                    mascot_modification.modification, i);
                 }
-              peptide_sp.get()->addAaModification(
-                mascot_modification.modification, i);
             }
           catch(pappso::PappsoException &error)
             {