added some comments while reading through code