improve code, update doc