added comments throughout