When you find the target you should then apply effects in the same action, you can use one tidy function that applies status X from attacker X to target X, you can send both through the function as parameters. Sending UID through ensures you are picking the right target and it shows up in logging, it's good for minimizing bugs and gives you some control within the loops.