onBeforeAction hook instead of before