added some useful comments along the code