fix bug about loop reset