diff --git a/src/bamToBed/bamToBed.cpp b/src/bamToBed/bamToBed.cpp
index ac30932387132c15f58c0399bc002db0fdccac12..684e835eb1833108459861e48e8fac8b24add14f 100755
--- a/src/bamToBed/bamToBed.cpp
+++ b/src/bamToBed/bamToBed.cpp
@@ -402,8 +402,7 @@ void PrintBedPE(const BamAlignment &bam1, const BamAlignment &bam2, const RefVec
 		swap(chrom1, chrom2);
 		swap(start1, start2);
 		swap(end1, end2);
-		swap(strand1, strand2);
-		if (useEditDistance == true) swap(editDistance1, editDistance2);		
+		swap(strand1, strand2);		
 	}
 
 	// report BEDPE using min mapQuality
diff --git a/src/pairToBed/pairToBed.h b/src/pairToBed/pairToBed.h
index 239c6fc6d458e0cac2d1e849622de6f775e93e9c..479c7bfe718cae0c63fae754c72339982d987483 100755
--- a/src/pairToBed/pairToBed.h
+++ b/src/pairToBed/pairToBed.h
@@ -126,6 +126,14 @@ private:
 			}
 		}
 		
+		// swap the ends if necessary
+		if ( a.chrom1 > a.chrom2 || ((a.chrom1 == a.chrom2) && (a.start1 > a.start2)) ) {
+			swap(a.chrom1, a.chrom2);
+			swap(a.start1, a.start2);
+			swap(a.end1, a.end2);
+			swap(a.strand1, a.strand2);	
+		}
+			
 		// compute the minimum mapping quality b/w the two ends of the pair.
 		a.score = "0";
 		if (_useEditDistance == false) {