fix some bugs, format output