fixed bugs in early stopping