diff --git a/metis_l1_prep.pro b/metis_l1_prep.pro
index 6e1492977bccb24d5cf0131e8ea41083e1cfb5ed..85a7191bd346025692bb8293bee3cd596ebe2515 100755
--- a/metis_l1_prep.pro
+++ b/metis_l1_prep.pro
@@ -205,6 +205,13 @@ pro metis_l1_prep
 
 		bad_pixel_map = readfits(cal_pack.path + channel.bad_pixel_map[0].file_name, /silent)
 
+		; adjust the map based on the presence of the reference rows
+		
+		map_size = size(bad_pixel_map)
+		ref_rows = fxpar(primary_header, 'REF_ROWS', missing = -1)
+		if ref_rows ge 0 then first_row = ref_rows ? 2 : 0 else first_row = 0
+		bad_pixel_map = bad_pixel_map[*, first_row : first_row + map_size[1] - 1]
+
 		; rebin the bad-pixel map to the size of the image to be corrected
 
 		bad_pixel_map = rebin(bad_pixel_map, naxis1, naxis2) * bin_fact^2