code style.
improve checks before resetting an index.