more doc and refactoring