reformat and fix bug