fix some bugs and improve