Cannot get average to calculate correctly in tutorial