Add code to average error