added a few comments and explanations