reformat and document the code