reformat and remove unnecessary code