added comments to make code easier to read