fix for avg calculations