Modified logic to use flags for HitAction