add rescue for NaN error in average calculator
merge