update permission and fix some bugs