In my opinion it is better to separate a solution to a particular problem into logical functions, each function doing exactly one thing (and one thing only), and then the program, which is a collection of functions, solves the problem. Not only does it make it far easier to analyze the problem and distribute the responsibility of the "work" logically, it is a cornerstone of code re-use.
In this case I see a total of 4 functions: one to find mirrored inserts, one to cycle thru a selection set and apply an affect to the members of that selection set, one that applies a specific effect upon an entity and then finally a c:function which calls the afore mentioned functions comprising "the solution" appropriately such that the problem is solved and accessible to the user as a command line utility.
Passing batton ...
Edit: Removed superfluous code.