Refactor and update doc