cleaned and added some comments