Added indexing for grouping messages