(a) Before Modification
 int offsetTmp = dataGridDisplayCriteria
     .getItemsPerPage() *
     (dataGridDisplayCriteria.getPage() -1);
  if (offsetTmp > 0) --offsetTmp;
  if (offsetTmp < 0) offsetTmp = 0;
 final int offset = offsetTmp;
  String sortColumn =
       dataGridDisplayCriteria.getSortColumn();
 Order orderTmp =
     dataGridDisplayCriteria.getOrder()
       .equals(AdServerBeansConstants.ASC) ?
           Order.asc(sortColumn)  :
              Order.desc(sortColumn);
(b) After 1st Modification
 int offsetTmp = dataGridDisplayCriteria
     .getItemsPerPage() *
         (dataGridDisplayCriteria.getPage() -1);
  if (offsetTmp > 0) --offsetTmp;
  if (offsetTmp < 0) offsetTmp = 0;
 final int offset = offsetTmp;
 String sortColumn =
%   dataGridDisplayCriteria.sortColumn;
 Order orderTmp =
%    dataGridDisplayCriteria.order
       .equals(AdServerBeansConstants.ASC) ?
          Order.asc(sortColumn)  :
             Order.desc(sortColumn);
(c) After 2nd Modification
 int offsetTmp = dataGridDisplayCriteria
     .getItemsPerPage() *
       (dataGridDisplayCriteria.getPage() -1);
#
  if (offsetTmp < 0) offsetTmp = 0;
 final int offset = offsetTmp;
 String sortColumn =
     dataGridDisplayCriteria.sortColumn;
 Order orderTmp =
     dataGridDisplayCriteria.order
     .equals(AdServerBeansConstants.ASC) ?
        Order.asc(sortColumn)  :
           Order.desc(sortColumn);
Algorithm 2: An example of unstable duplicate code.