how about ah.user.manages_team(team_name) instead of this complex boolean query. Also for sanity can you bracket the first half of this so that it's obvious that it's (not instance.is_blueshirt) instead of not (whole_thing)