How do I create a buy 1 get 1 free script with specific discount codes?

Hi,

I’d like to create a Buy 1 Get 1 Free script that is qualified by the following:

  1. Specific Discount code that contains a specific set of letters.

  2. The Item in cart must be a minimum of x1 and must have a certain tag.

  3. The Free item can be within a certain collection (broader set of items than point #2).

  4. Can do this in unlimited sets of 2. ie: Buy x1 “qualifying item A” get x1 “qualifying item A” Free …multiple times in a single order with different sets of qualifying items. Like a normal Shopify+ Bogo Discount. However in this case I need it to initialize with a specific set of discount codes (point 1)

I tried to create this code almost successfully, I just can’t seem to get it so if the customer orders the qualifying items from point more than once it ends up giving both items within the set a 100% discount. See Screeshot below and code attached