Add document and some modification of code