fix group by envelop calc