Comments added explaining what the code does