It's correct but potentially confusing (of course your parenthetical notes remove the confusion and are an acceptable solution in rare cases). In general you should always be aware of your pronoun usage and reword your work if necessary to avoid such confusion. On a more general note I find it very annoying when people are sloppy with their pronouns.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.