fix rms calculation