added comments and explanatory text