This code is very bad. If the team had 100 members, 100 queries run in this action. It makes this app much slower.