added some comments in code