add comments
fix some bugs