Single function for event detection
Handle empty dataset