Added a bunch of comments that explain the code well