made selecting roles more efficient by extracting roles to a var before
loop