added some comments as well as changed some codes