added comments and formating