Added comments to increase understandability of code.