added some comments to code
fixed merge conflicts