fix for leastsquare: making its output consistent either by detection in per trial basis or for the whole file basis