fix loop bug for undispersed data sets