minor tweaking of the code and reformat