Limitation of cart transformation function

When I was trying out a cart transformation function that adds a line expand operation. I want to give a free gift card product using it. But when I add more than 1 quantity that many quantities of the gift card is getting added into the line item. Like this image:

How to achieve only one gift card to be added irrespective of the quantity?