It's a little more conventional to put this kind of logic ABOVE any render/redirects for the action.