Easiest way would be to use an instance variable (on the family?) instead of a global variable..
You aren't referencing an instance right now, so the action is performed on all instances..
If you search the forum for "select instance" you will probably find many examples..