Adding hooks for 'beforeNext' and 'beforeBack'