refactoring and add doc