add some comment, reordering the code structure