added grand_average function