solve some bugs & add some explanation