It's a classic picking problem.
If you don't pick an object instance inside the function definition, the function will work on all instances of that object.
Like DUTOIT said, you have to pass your object's UID to the function, and inside the function you need to use system's "pick by unique ID" using that parameter.