Updated code layout to make it more beautiful, and added comments