added a bunch of comments and reformatted to my personal liking