set beforeRouting to only get called when page is actually being changed