added comments and explanations to code