add doc & refactor