Add function doc; eggpainly change the way of implementation

agree?