Fixed Crappy group by max implementation