improved header handling for group by!