diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index ebe60f5..2dde896 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -8,9 +8,12 @@ Release Notes
    ==================
 
 
-0.7.2 (06-May-2021)
+0.7.2 (07-May-2021)
 ===================
 
+- Fixed a bug in ``matchutils._find_peak()`` due to which it could return
+  coordinates of the peak that were outside of the image. [#136]
+
 - Fixed a bug in how re-projection was computed when ``center`` of the
   transformations was provided. [#135]
 
diff --git a/tweakwcs/matchutils.py b/tweakwcs/matchutils.py
index 9fd05e9..6def57b 100644
--- a/tweakwcs/matchutils.py
+++ b/tweakwcs/matchutils.py
@@ -518,12 +518,12 @@ def _find_peak(data, peak_fit_box=5, mask=None):
     ym = (c10 * c11 - 2.0 * c01 * c20) / det
 
     if 0.0 <= xm <= (nx - 1.0) and 0.0 <= ym <= (ny - 1.0):
-        coord = (xm, ym)
         fit_status = 'SUCCESS'
-
     else:
         xm = 0.0 if xm < 0.0 else min(xm, nx - 1.0)
         ym = 0.0 if ym < 0.0 else min(ym, ny - 1.0)
         fit_status = 'WARNING:EDGE'
 
+    coord = (xm, ym)
+
     return coord, fit_status, np.s_[y1:y2, x1:x2]

diff --git a/tweakwcs/tests/test_matchutils.py b/tweakwcs/tests/test_matchutils.py
index a390812..59d6dd3 100644
--- a/tweakwcs/tests/test_matchutils.py
+++ b/tweakwcs/tests/test_matchutils.py
@@ -189,7 +189,7 @@ def test_find_peak_fit_over_edge():
     data[:, 0] = 0.0
     coord, fit_status, fit_box = _find_peak(data, peak_fit_box=7)
     assert fit_status == 'WARNING:EDGE'
-    assert np.allclose(coord, (1, 11), rtol=0, atol=1e-6)
+    assert np.allclose(coord, (0, 11), rtol=0, atol=1e-6)
 
 
 @pytest.mark.parametrize('shift', [100, 2])

Peak measurement of 2d histogram can find unrealistic positions for the peak
Processing the singleton 'ibbr02c5q' triggers a logical error when determining the position of the peak of the 2d histogram.  

Specifically, Line 489 of `matchutils.py` in the `_find_peak()` function can return a solution that ends up outside the range of values defined by the slice being used for the fit defined by (x1, x2), (y1,y2).  Logic needs to be added to look for this situation and trigger the failure mode to revert to simply reporting the position of the max value instead as currently happens now when the 'det <= 0' in Line 513.  The current logic does not prevent this function from returning values outside of the slice defined for the peak.
tweakwcs/tests/test_matchutils.py::test_find_peak_fit_over_edge
tweakwcs/tests/test_matchutils.py::test_xy_2dhist tweakwcs/tests/test_matchutils.py::test_find_peak_nodata_all_zeros[shape0-None] tweakwcs/tests/test_matchutils.py::test_find_peak_nodata_all_zeros[shape1-0] tweakwcs/tests/test_matchutils.py::test_find_peak_nodata_all_zeros[shape2-1] tweakwcs/tests/test_matchutils.py::test_find_peak_nodata_all_zeros[shape3-None] tweakwcs/tests/test_matchutils.py::test_find_peak_nodata_all_zeros[shape4-0] tweakwcs/tests/test_matchutils.py::test_find_peak_nodata_all_zeros[shape5-1] tweakwcs/tests/test_matchutils.py::test_find_peak_nodata_all_zeros[shape6-None] tweakwcs/tests/test_matchutils.py::test_find_peak_nodata_all_zeros[shape7-0] tweakwcs/tests/test_matchutils.py::test_find_peak_nodata_all_zeros[shape8-1] tweakwcs/tests/test_matchutils.py::test_find_peak_edge_1pix_valid_strip[True] tweakwcs/tests/test_matchutils.py::test_find_peak_edge_1pix_valid_strip[False] tweakwcs/tests/test_matchutils.py::test_find_peak_nodata_peak_is_invalid tweakwcs/tests/test_matchutils.py::test_find_peak_few_data_center_of_mass tweakwcs/tests/test_matchutils.py::test_find_peak_few_data_for_center_of_mass tweakwcs/tests/test_matchutils.py::test_find_peak_negative_peak tweakwcs/tests/test_matchutils.py::test_find_peak_tiny_box_1pix tweakwcs/tests/test_matchutils.py::test_find_peak_negative_box_size tweakwcs/tests/test_matchutils.py::test_find_peak_success tweakwcs/tests/test_matchutils.py::test_find_peak_fail_lstsq tweakwcs/tests/test_matchutils.py::test_find_peak_nodata_after_fail tweakwcs/tests/test_matchutils.py::test_find_peak_badfit tweakwcs/tests/test_matchutils.py::test_estimate_2dhist_shift_one_bin[100] tweakwcs/tests/test_matchutils.py::test_estimate_2dhist_shift_one_bin[2] tweakwcs/tests/test_matchutils.py::test_estimate_2dhist_shift_edge tweakwcs/tests/test_matchutils.py::test_estimate_2dhist_shift_fit_failed tweakwcs/tests/test_matchutils.py::test_estimate_2dhist_shift_two_equal_maxima tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_pars[0-1-1] tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_pars[1-0-1] tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_pars[1-1-0] tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_call_pars[refcat0-imcat0-None-TypeError] tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_call_pars[refcat1-imcat1-None-ValueError] tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_call_pars[refcat2-imcat2-None-TypeError] tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_call_pars[refcat3-imcat3-None-ValueError] tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_call_pars[refcat4-imcat4-None-KeyError] tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_call_pars[refcat5-imcat5-None-KeyError] tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_call_pars[refcat6-imcat6-None-KeyError] tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_call_pars[refcat7-imcat7-None-KeyError] tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_call_pars[refcat8-imcat8-tp_wcs8-KeyError] tweakwcs/tests/test_matchutils.py::test_tpmatch_bad_call_pars[refcat9-imcat9-tp_wcs9-KeyError] tweakwcs/tests/test_matchutils.py::test_tpmatch[None-False] tweakwcs/tests/test_matchutils.py::test_tpmatch[None-True] tweakwcs/tests/test_matchutils.py::test_tpmatch[tp_wcs2-False] tweakwcs/tests/test_matchutils.py::test_tpmatch[tp_wcs3-True] tweakwcs/tests/test_matchutils.py::test_match_catalogs_abc