modify according to comments, and reformat code style