added comments to code for easier reading.