added comments, code formatting
added comments and code formatting