update and fix some bugs