add more sql,  add more comment, fix some bugs