refactor
fix some bugs