adding a bunch of comments, making some variable names more explicit