added sorting/grouping by time