fixed initialisation. Code runs well (and faster?) the first time, but stalls the second (NaN when computing average)