optimize code style, add some comments