fix some bug, format the code