change some function names and add some comments