fixed group by time, added group by group