add some comments, fix a bug