def filter_merged(merged_df, off_target_max):
    """
    Filters the merged df to find only primers which align with initial primer pairs, and have a value
    below off target threshold.
    Args:
        merged_df (DataFrame): output df from merge_good_total()
        off_target_max (int): the maximum number of off target sites allowed (<= this value)
    Returns:
        off_target_filtered (DataFrame): the filtered dataframe
    """
    filtered_df = merged_df.loc[(merged_df['Primer Left Seq'] == merged_df['Forward']) &
                                (merged_df['Primer Right Seq'] == merged_df['Reverse'])]
    useful_filtered = filtered_df[['Sequence ID', 'Primer Rank', 'Primer Left Seq',
                                   'Primer Right Seq', 'Primer Left Len', 'Primer Right Len',
                                   'Primer Left TM', 'Primer Right TM', 'Primer Left GC %',
                                   'Primer Right GC %', 'Chromosome', 'Position1',
                                   'Position2', 'PCR_Prod_Len',
                                   'Product GC%', 'FwdPrimerPos', 'RvsPrimerPos', 'OffTargetCount']]
    off_target_filtered = useful_filtered.loc[useful_filtered['OffTargetCount'] <= off_target_max]
    return off_target_filtered