merging with beforeRouting