Fixed group by bug