Correct a bug in reset function.