Replaced redundant when statements with a case statement for event type filtering