Add comments to clarify components of main function