Made some slight adjustments and added some comments