fix average error computation