add some comments. change some method to private