fix some bugs, and use spaces instead of tab