Changed code to average error over multiple runs.