Added a `beforeRouting` method.
merging with beforeRouting