added beforeTransition hook