fix bug and add the doc for function