reformat
some bugs fix