code refactoring and reset added #3