added comments to clarify lines of code