Removed unneccesary group by clauses