you don't really need to have a useTarget boolean.  just set the communityId here using getHCIDFromTarget() and then on the else, set the communityId using getHCIDFromAssertion()