analyzed and added some comments