Method and system for grouping events