Add comments to clarify logic