update doc / improve code