fix an error in maxlag detection