1. Better to contain this whole code block in a function of its own, to keep the controller logic simple.
2. Can you wrap with a settings flag that controls whether this enabled or disabled? While we can use '*' to enable all tables for all users, this check for one statement at a time is a problem for us. Better to be able to disable this when unnecessary instead of complicating your logic.