reformat the code and add some notation