add denorminater for the correlation function and make the loop over events work for any size of the buffer