diff --git a/patches/gromacs-5.1.2.diff/src/programs/mdrun/repl_ex.cpp b/patches/gromacs-5.1.2.diff/src/programs/mdrun/repl_ex.cpp
index 63eac8236921fb0dbc752d02315f01aea7a09acf..e799bc66964a891d20d901b8fd0e543a9cfc03a3 100644
--- a/patches/gromacs-5.1.2.diff/src/programs/mdrun/repl_ex.cpp
+++ b/patches/gromacs-5.1.2.diff/src/programs/mdrun/repl_ex.cpp
@@ -895,6 +895,11 @@ static real calc_delta(FILE *fplog, gmx_bool bPrint, struct gmx_repl_ex *re, int
     {
         fprintf(fplog, "Repl %d <-> %d  dE_term = %10.3e (kT)\n", a, b, delta);
     }
+
+/* this is necessary because with plumed HREX the energy contribution is
+   already taken into account */
+    if(plumed_hrex) delta=0.0;
+
     if (re->bNPT)
     {
         /* revist the calculation for 5.0.  Might be some improvements. */
@@ -1117,9 +1122,6 @@ test_for_replica_exchange(FILE                 *fplog,
             if (i % 2 == m)
             {
                 delta = calc_delta(fplog, bPrint, re, a, b, a, b);
-/* this is necessary because with plumed HREX the energy contribution is
-   already taken into account */
-                if(plumed_hrex) delta=0.0;
 
                 /* PLUMED */
                 if(plumedswitch){