added some doc and refactoring