Change a lot

merge the other’s code and fix the bugs.