added comments to explain what my code is doing