local function checkForMatch(circle) local game = circle.parent local circles = game.circles local matches = {} matches.number = 1 matches[circle] = circle local function recurse(circle) for i, circle2 in pairs(circles) do if isMatch(circle, circle2) and not matches[circle2] then matches[circle2] = circle2 matches.number = matches.number + 1 recurse(circle2) end end end recurse(circle) if matches.number > 2 then for i, circle in pairs(matches) do local i2 = table.indexOf(circles, circle) if i2 then table.remove(circles, i2) end circle:removeSelf() end end end