fix some bugs and make it work!