fix some bugs, just for test, GUI to be done