#added comments and code formatted