fixed and added some comments