A few questions.
- Is the variable 'c' a local variable, and not in the global namespace?
- 'c' is not descriptive. What does it do? Where do you use it? In a year, 'c' will not mean anything to you, nor anyone else. If it is colours, call it 'MyAddOnName_UnitColors' or something that tells you what use it serves.
- In your event handler function, you are not checking for if event == "EVENT_NAME" then...
- Since you are only checking for focus and target, why register the other events?
As for "is there a better way", if you could be more forthcoming about what you are trying to do
overall, that would help. Right now, you haven't posted enough code to properly answer.